码迷,mamicode.com
首页 > 其他好文 > 详细

hdoj-2273-The buses

时间:2015-07-22 22:52:24      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

The buses

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 623 Accepted Submission(s): 312


Problem Description
Garfield applied for a good job recently, and he will go to work soon by car or bus. Garfield is very broody, sometimes when he sits on the bus to wait for the traffic light, he thinks about how long all the buses pass the traffic turning.
Now we describe the situations when the buses stop at the traffic turning to wait for the traffic light. First the light is red, then when the light changes to green, all the buses are prepared to move. And at the beginning, all the buses are close to each other without any space, and they have different lengths and the largest speeds. We assume any car can reach the speed that isn’t beyond the maximal speed at once.
Now Garfield wants you to calculate minimal time all the buses pass the turning.


Input
There are many cases. For each case, there is two intergers N(1<=N<=100), representing the number of the buses. There are two interges in the following N lines, for the length Li(meter, 1<=Li<=10) and the maximal speed Si(meter/second, 1<=Si<=10) of the i-th bus.

Output
For each case, print the result obtaining two digits after the decimal point.

Sample Input
2 1 2 2 3

Sample Output
1.50

Source

Recommend
lcy | We have carefully selected several similar problems for you: 2274 2276 2278 2279 2275

#include<stdio.h>
#include<algorithm>
using namespace  std;
int main(){
	int n;
	while(~scanf("%d",&n)){
		int as=0,a,b;
		int v=111;
		for(int i=0;i<n;++i){
			scanf("%d%d",&a,&b);
			as+=a;
			v=min(v,b);
		}
    	printf("%.2lf\n",1.0*as/v);
	} 
	return 0;
}


=>> 所有车排成一列,当绿灯时,所有车以最大车速最小的速度前行(以防碰撞),所以time= 最后一辆车的用时

版权声明:本文为博主原创文章,未经博主允许不得转载。

hdoj-2273-The buses

标签:

原文地址:http://blog.csdn.net/qq_18062811/article/details/47010259

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!