POJ 1922 Ride to School

Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 19986   Accepted: 8058

Description

Many graduate students of Peking University are living in Wanliu Campus, which is 4.5 kilometers from the main campus – Yanyuan. Students in Wanliu have to either take a bus or ride a bike to go to school. Due to the bad traffic in Beijing, many students choose to ride a bike.

We may assume that all the students except "Charley" ride from
Wanliu to Yanyuan at a fixed speed. Charley is a student with a
different riding habit – he always tries to follow another rider to
avoid riding alone. When Charley gets to the gate of Wanliu, he will
look for someone who is setting off to Yanyuan. If he finds someone, he
will follow that rider, or if not, he will wait for someone to follow.
On the way from Wanliu to Yanyuan, at any time if a faster student
surpassed Charley, he will leave the rider he is following and speed up
to follow the faster one.

We assume the time that Charley gets to the gate of Wanliu is zero.
Given the set off time and speed of the other students, your task is to
give the time when Charley arrives at Yanyuan.

Input

There
are several test cases. The first line of each case is N (1 <= N
<= 10000) representing the number of riders (excluding Charley). N =
0 ends the input. The following N lines are information of N different
riders, in such format:

Vi [TAB] Ti

Vi is a positive integer <= 40, indicating the speed of the i-th
rider (kph, kilometers per hour). Ti is the set off time of the i-th
rider, which is an integer and counted in seconds. In any case it is
assured that there always exists a nonnegative Ti.

Output

Output one line for each case: the arrival time of Charley. Round up (ceiling) the value when dealing with a fraction.

Sample Input

4
20	0
25	-155
27	190
30	240
2
21	0
22	34
0

Sample Output

780
771

CODE:
时间: 2024-08-05 20:05:35

POJ 1922 Ride to School的相关文章

贪心/poj 1922 Ride to School

1 #include<cstdio> 2 #include<cmath> 3 using namespace std; 4 int n,ans,v,t; 5 int main() 6 { 7 scanf("%d",&n); 8 while (n!=0) 9 { 10 ans=0x7fffffff; 11 for (int i=1;i<=n;i++) 12 { 13 scanf("%d%d",&v,&t); 14

POJ 1922 Ride to School#贪心

(- ̄▽ ̄)-* //C跟着a君骑,然后更快的b君来了,C又跟着b君骑, //接着最快的d君来了,C就去跟着d君了, //最后最快的d君到达目的地时,C也就到了 //所以C的到达时间,就是最早到达的那个人的到达时间 //tips:但是,ti为负数者,速度又快的话,那C是永远追不上的 //所以结果应该是ti为正,即在C后才出发,的最快者所用时 #include<iostream> #include<cstdio> #include<cstring> #include<

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

转载:poj题目分类(侵删)

转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K–0.50K:中短代码:0.51K–1.00K:中等代码量:1.01K–2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348

poj题库分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目(转)

http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (

Poj 题目分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea

POJ题目分类(转)

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea