POJ-1922 Ride to School
Ride to School
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 20162 | Accepted: 8138 |
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.
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.
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
Source
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,i;
double v,t,x,min;
while(cin>>n&&n!=0)
{
min=1e100;
for(i=0; i<n; ++i)
{
cin>>v>>t;
x=t+(4.5*3600/v);
if(x<min&&t>=0)
min=x;
}
cout<<ceil(min)<<endl;
}
return 0;
}
相關文章
- School New Competition WP
- 起亞汽車廣告One Epic RideIDE
- W3School教程整理
- CSS tutorials (w3school)CSS
- 前端知識:w3school前端
- school dictionary, kids dictionary, children dictionary
- HTML <!DOCTYPE> (轉自w3school)HTML
- W3school的CSS筆記(定位)CSS筆記
- Robotframework-ride 日誌輸出中文亂碼FrameworkIDE
- W3school的CSS筆記(框模型)CSS筆記模型
- 中國學生的福利 蘋果“Back to school ”來了蘋果
- USACO第一題RIDE,我的飛船在哪裡IDE
- W3school的CSS筆記(基礎篇)CSS筆記
- W3school的Html5新標籤HTML
- Robot Framework-Ride建立桌面快捷方式(最簡單!)FrameworkIDE
- RIDE匯入AutoItLibrary的安裝以及遇到的問題IDE
- RIDE+Selenium2Library呼叫PyMouse進行滑鼠操作IDE
- 自動化測試 RobotFramework-ride使用相關總結FrameworkIDE
- 【數論】Codeforces Round #404 (Div. 2)(D)Anton and School - 2
- ride中引用Selenium2Library一直報錯IDE
- 程式設計師必讀期刊之 Journal of School Psychology程式設計師
- On-site question removal + direct interview | Meituan technical school recruitment live broadcast is here!REMViewUIAST
- The 2024 Hunan Multi-School Programming Training Contest, Round 4NaNAI
- python(建立一個school的簡單django專案以及相關配置、完成school專案的models模板與檢視views的編寫—index(首頁)、add(新增學生))PythonDjangoViewIndex
- 毫末智行與高通宣佈採用Snapdragon Ride平臺打造全新智慧駕駛解決方案GoIDE
- 在W3C SCHOOL網站上發現一個關於Schema的錯誤網站
- Netflix 宣佈收購《奧森弗裡》開發商 Night School 工作室