Speed Limit



Bill and Ted are taking a road trip. But the odometer in their car is broken, so they don't know how many miles they have driven. Fortunately, Bill has a working stopwatch, so they can record their speed and the total time they have driven. Unfortunately, their record keeping strategy is a little odd, so they need help computing the total distance driven. You are to write a program to do this computation. 

For example, if their log shows 
Speed in miles perhourTotal elapsed time in hours
202
306
107

this means they drove 2 hours at 20 miles per hour, then 6-2=4 hours at 30 miles per hour, then 7-6=1 hour at 10 miles per hour. The distance driven is then (2)(20) + (4)(30) + (1)(10) = 40 + 120 + 10 = 170 miles. Note that the total elapsed time is always since the beginning of the trip, not since the previous entry in their log.

Input

The input consists of one or more data sets. Each set starts with a line containing an integer n, 1 <= n <= 10, followed by n pairs of values, one pair per line. The first value in a pair, s, is the speed in miles per hour and the second value, t, is the total elapsed time. Both s and t are integers, 1 <= s <= 90 and 1 <= t <= 12. The values for t are always in strictly increasing order. A value of -1 for n signals the end of the input. 

Output

For each input set, print the distance driven, followed by a space, followed by the word "miles"

Sample Input

3
20 2
30 6
10 7
2
60 1
30 5
4
15 1
25 2
30 3
10 5
-1

Sample Output

170 miles
180 miles
90 miles


水题,模拟直接过


#include<iostream>
using namespace std;
int main()
{
	int n;
	int a[100],b[100],sum;
	while(cin>>n)
	{
		if(n==-1)
			break;
		sum=0;
		int x;
		for(int i=0;i<n;i++)
		{
			cin>>a[i]>>b[i];
		}
		x=b[0]*a[0];sum=x;
		for(int i=1;i<n;i++)
		{
			sum+=(b[i]-b[i-1])*a[i];
		}
		cout<<sum<<" miles"<<endl;
	}


}






在Apollo中,speed limit是通过多个模块共同计算得出的。其中包括Speed_bounds_prior_decider、DP_ST_SPEED_OPTIMIZER、SPEED_DECIDER、SPEED_BOUNDS_FINAL_DECIDER和PIECEWISE_JERK_SPEED_OPTIMIZER等模块。首先,Speed_bounds_prior_decider将障碍物的轨迹映射到s-t图,计算出障碍物的轨迹并将其放置在boundaries集合中,然后设置速度的最大限制。接下来,DP_ST_SPEED_OPTIMIZER根据这些boundaries进行启发式速度曲线搜索,得到最优轨迹。然后,SPEED_DECIDER根据速度曲线初步判断障碍物的decision,并对行人进行特殊处理以设置相应的决策行为。之后,SPEED_BOUNDS_FINAL_DECIDER重新计算障碍物的st边界,并根据障碍物的decision确定速度的边界。最后,PIECEWISE_JERK_SPEED_OPTIMIZER使用osqp进行数值优化计算,得出最优的速度曲线。综合以上模块的计算,才得出Apollo中的speed limit。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [搭建Apollo配置中心](https://download.csdn.net/download/weixin_38663197/13687280)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Apollo 算法阅读之Public Road轨迹规划算法--速度规划](https://blog.csdn.net/weixin_41399111/article/details/106323799)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值