hdoj-2273-The buses
2015-07-22 21:45
274 查看
The buses
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 623 Accepted Submission(s): 312
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, print the result obtaining two digits after the decimal point.
[align=left]Sample Input[/align]
2 1 2 2 3
[align=left]Sample Output[/align]
1.50
[align=left]Source[/align]
HDU 8th Programming Contest Site(1)
[align=left]Recommend[/align]
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= 最后一辆车的用时
相关文章推荐
- 杭电1129 Do the Untwist
- poj 3723 Conscription (最小生成树)
- 算法之二分查找(1)
- 如何将一个字符串倒序输出
- XML解析
- 51-android.rules详解
- iOS本地国际化处理自己封装好的宏
- ios结构体
- iOS开发入门教程 iPhone开发相关学习资料
- 数据库设计(二)——数据类型
- 说说nio----1
- 2015 多校赛 1002 (hdu 5289)
- 说说nio----1
- 2015年7月21日
- 暑假集训第二周——递推 骆驼猜名字
- Problem B 队列
- 队列 Soldier and Cards
- 数据成员的存取与布局
- 【云快讯】之五十二《华为的公有云即将发布,名字还是个谜》
- c/C++程序内存分配方式