电车痴汉

描述
Many staff of are living in a place called MZone, far from their office( 4.5 km ). Due to the bad traffic, many staff choose to ride a bike.

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

We assume the time that Weiwei gets to the gate of MZone is zero. Given the set off time and speed of the other people, your task is to give the time when Weiwei arrives at his office.

输入
There are several test cases. The first line of each case is N (1 <= N <= 10000) representing the number of riders (excluding Weiwei). 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 one line for each case: the arrival time of Weiwei. Round up (ceiling) the value when dealing with a fraction.
样例输入
4
20  0
25  -155
27  190
30  240
2
21  0
22  34
0
样例输出
780
771

对于n个骑行者,你,电车痴汉,从时刻0开始出发,谁快就跟着谁。

恍惚间,你会发现你最后一个尾随的人到达的时间就是你最快的时间,因为用时最少那么他一定会追上你,你一定会最后跟着他走,他到达的时间也就是你达到的最少时间了
t<0不用考虑,人家早跑了你尾行谁去?

#include<cmath>
#include<cstdio>
#include<iostream>
#define N 10010
using namespace std;
const int inf=1<<30;
int v,t;
int n,ans;
int main(){while (scanf("%d",&n) && n){ans=inf;for (int i=1;i<=n;i++){scanf("%d%d",&v,&t);if (t<0) continue;int time=(int) ceil(4.5/v * 3600) +t;ans=min(ans,time);}printf("%d\n",ans);}return 0;
}

[openjudge] Ride to Office相关推荐

  1. 信息学奥赛一本通 1227:Ride to Office | OpenJudge NOI 4.6 2404:Ride to Office

    [题目链接] ybt 1227:Ride to Office OpenJudge NOI 4.6 2404:Ride to Office 原题是英文题,虽说两题题意相同,但一本通网站没有对该问题进行直 ...

  2. 信息学奥赛一本通(1227:Ride to Office)

    1227:Ride to Office 时间限制: 1000 ms         内存限制: 65536 KB 提交数: 5002     通过数: 2822 [题目描述] 起点与终点相隔4500米 ...

  3. 1227:Ride to Office

    题目来源:http://ybt.ssoier.cn:8088/problem_show.php?pid=1227 1227:Ride to Office 时间限制: 1000 ms         内 ...

  4. Ride to Office(信息学奥赛一本通-T1227)

    [题目描述] 起点与终点相隔4500米.现Charley 需要从起点骑车到终点.但是,他有个习惯,沿途需要有人陪伴,即以相同的速度, 与另外一个人一起骑.而当他遇到以更快的速度骑车的人时,他会以相应的 ...

  5. D29:Post Office(邮局,翻译)

    原题:OpenJudge - 162:Post Office 翻译: 描述:有一条笔直的公路,公路旁边有村庄.公路表示为一个整数轴,每个村庄的位置用一个单一的整数坐标来标识.村庄处于不同位置.两个位置 ...

  6. 基础算法 —— 贪心算法

    [概述] 贪心算法是从问题的初始状态出发,通过若干次的贪心选择而得到的最优值的一种求解策略,即贪心策略. 简单来说,贪心策略是一种在每次决策时采取当前意义下最优策略的算法,做出的选择至少在某种约束条件 ...

  7. C++奥赛一本通贪心题解

    C++奥赛一本通刷题记录(贪心) 2017.11.15 By gwj1139177410 书不见了,占坑待填. An Easy Problem poj2453 //贪心, 将最右边第一个01改成10并 ...

  8. 贪心题集(vjoj)

    首先总结一下贪心,算法贪心算法(重点就是一个贪字)是指,在对问题求解时,总是做出在当前看来是最好的选择.也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解,而每个局部最优解的总和就 ...

  9. 信息学奥赛一本通(基础算法与数据结构-题解汇总目录)

    信息学奥赛一本通(C++版)在线评测系统 基础(二)基础算法   更新中...... 第一章高精度计算 1307[例1.3]高精度乘法 1308[例1.5]高精除 1309[例1.6]回文数(Noip ...

最新文章

  1. TensorFlow 2.0来了,为什么他却说“深度学习框架之争,现在谈结果为时尚早”?...
  2. 别乱提交代码了,看下大厂 Git 提交规范是怎么做的!
  3. html内容显示重叠了,HTML:将DIV内容并排放置而不重叠
  4. 支付宝支付后回调通知中responseTxt=true isSign=False可能的问题
  5. python argparse理解与实例
  6. APP远程调试及网络自动化测试
  7. ICCV2015上的GazeTracker论文总结
  8. Spring MVC表单教程
  9. 正则表达式怎样匹配 不包含特定字符串的字符串
  10. 枚举算法:试统计正整数n的阶层n!=1*2*...*n尾部连续零的个数。
  11. 第10章 十字消除(《C和C++游戏趣味编程》配套教学视频)
  12. Markdown学习指南
  13. canpro脚本_shell脚本实现-----自动巡检脚本.sh
  14. 区块链Baas应用服务平台开发搭建
  15. pythonarray去除inf_Python中的inf与nan
  16. 单机魔域显示服务器未启动,魔域单机版_开始游戏
  17. 【产品分析】共享充电宝
  18. SQL的删除语句delete(删除表中的数据)
  19. Python爬虫学习之爬取财富快讯
  20. windows查看并获取文件的md5值

热门文章

  1. 掌上医院HTML模板,易就医(掌上医院服务)app
  2. 真正的文盲:没有文化的文化人系列
  3. C语言入门篇——输入输出篇
  4. 美国正在失去对百万富翁移民的吸引力 | 美通社头条
  5. 英语日常口语对话(4)
  6. 学习ArcGIS?37个Arcmap常用操作技巧可能帮到您
  7. 25 | 固若金汤的根本(下):数字签名与证书
  8. 【软件测试笔试题】阿里巴巴(中国)网络技术有限公司
  9. laytpl语法_laytpl 精致巧妙的JavaScript模板引擎
  10. catBoost 神器的学习笔记