hdoj-2273-The buses

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

HDU 8th Programming Contest Site(1)

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= 最后一辆车的用时

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

时间: 2024-10-17 18:57:50

hdoj-2273-The buses的相关文章

【HDOJ】4328 Cut the cake

将原问题转化为求完全由1组成的最大子矩阵.挺经典的通过dp将n^3转化为n^2. 1 /* 4328 */ 2 #include <iostream> 3 #include <sstream> 4 #include <string> 5 #include <map> 6 #include <queue> 7 #include <set> 8 #include <stack> 9 #include <vector>

POJ Xiangqi 4001 &amp;&amp; HDOJ 4121 Xiangqi

题目链接(POJ):http://poj.org/problem?id=4001 题目链接(HDOJ):http://acm.hdu.edu.cn/showproblem.php?pid=4121 Xiangqi Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1108   Accepted: 299 Description Xiangqi is one of the most popular two-player boa

【HDOJ】4956 Poor Hanamichi

基本数学题一道,看错位数,当成大数减做了,而且还把方向看反了.所求为最接近l的值. 1 #include <cstdio> 2 3 int f(__int64 x) { 4 int i, sum; 5 6 i = sum = 0; 7 while (x) { 8 if (i & 1) 9 sum -= x%10; 10 else 11 sum += x%10; 12 ++i; 13 x/=10; 14 } 15 return sum; 16 } 17 18 int main() { 1

HDOJ 4901 The Romantic Hero

DP....扫两遍组合起来 The Romantic Hero Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 547    Accepted Submission(s): 217 Problem Description There is an old country and the king fell in love with a

【HDOJ】1099 Lottery

题意超难懂,实则一道概率论的题目.求P(n).P(n) = n*(1+1/2+1/3+1/4+...+1/n).结果如果可以除尽则表示为整数,否则表示为假分数. 1 #include <cstdio> 2 #include <cstring> 3 4 #define MAXN 25 5 6 __int64 buf[MAXN]; 7 8 __int64 gcd(__int64 a, __int64 b) { 9 if (b == 0) return a; 10 else return

【HDOJ】2844 Coins

完全背包. 1 #include <stdio.h> 2 #include <string.h> 3 4 int a[105], c[105]; 5 int n, m; 6 int dp[100005]; 7 8 int mymax(int a, int b) { 9 return a>b ? a:b; 10 } 11 12 void CompletePack(int c) { 13 int i; 14 15 for (i=c; i<=m; ++i) 16 dp[i]

HDOJ 3790 双权值Dijkstra

1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <cstring> 5 using namespace std; 6 7 const int INF = 1000000; 8 const int MAXSIZE = 1005; 9 10 int map[MAXSIZE][MAXSIZE]; 11 int price[MAXSIZE][MAXSIZE]; 1

HDOJ 1217 Floyed Template

1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <cstring> 5 #include<map> 6 using namespace std; 7 8 map<string,int>name; 9 const int INF = 1000000; 10 const int MAXSIZE = 1005; 11 const int

hdoj 4004 The Frog&#39;s Games(二分)

The Frog's Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 5676    Accepted Submission(s): 2732 Problem Description The annual Games in frogs' kingdom started again. The most famous game i

【HDOJ】4601 Letter Tree

挺有意思的一道题,思路肯定是将图转化为Trie树,这样可以求得字典序.然后,按照trie的层次求解.一直wa的原因在于将树转化为线性数据结构时要从原树遍历,从trie遍历就会wa.不同结点可能映射为trie上的同一结点,如1->2 (a) 1->3(a) 2->4(b), 这是trie的结构是RT->a->b.然而,从结点3不能找到权重为b的路径.用RMQ求满足边界的rank最大值,通过sa找到该最大值对应的trie上的根.从而求解. 1 /* 4601 */ 2 #incl