HDU 1445 Ride to School
http://acm.hdu.edu.cn/showproblem.php?pid=1445
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.
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.
题解:贪心
代码:
#include <bits/stdc++.h>
using namespace std; #define inf 0x3f3f3f3f
int n; struct Node {
int v;
int t;
int need;
}node[10000]; int main(){
while(~scanf("%d", &n)){
if(!n) break; for(int i = 0; i < n; i ++)
scanf("%d%d", &node[i].v, &node[i].t); for(int i = 0; i < n; i ++){
if(node[i].t < 0) {
node[i].need = inf;
} else{
node[i].need = (int)((4500 * 3.6) / node[i].v + node[i].t);
if((int)(4500 * 3.6) % node[i].v)
node[i].need ++;
}
} int ans = node[0].need;
for(int i = 1; i < n; i ++)
ans = min(ans, node[i].need); printf("%d\n", ans);
}
return 0;
}
HDU 1445 Ride to School的更多相关文章
- 【HDU 1445】Ride to School
题 题意 骑自行车,等0时开始最早出发的人,一起出发,然后被别人超过时,就追上去,终点距离是4.5km,速度单位是km/s,求到达的时间(s). 分析 贪心,找0时开始最早到的即可. 代码 #incl ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- HDU 5477 A Sweet Journey 水题
A Sweet Journey Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...
- [hdu P4114] Disney's FastPass
[hdu P4114] Disney's FastPass Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- hdu 4114 Disney's FastPass 状压dp
Disney's FastPass Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- hdu 3191 How Many Paths Are There (次短路径数)
How Many Paths Are There Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java ...
- HDU 1350 Taxi Cab Scheme
Taxi Cab Scheme Time Limit: 10000ms Memory Limit: 32768KB This problem will be judged on HDU. Origin ...
随机推荐
- 关于echarts整合多个类似option
最近项目里面遇到一些图表需要用echarts来做.而我之前只用过一次echarts,也只是做了一个简单的饼状图,并没有涉及到很多的配置.但是现在这个项目,这些图表需要自己配置很多东西.像什么多余的网格 ...
- HDU 6354--Everything Has Changed(判断两圆关系+弧长计算)
题目 题意:首先给定一个以原点为圆心,R为半径的圆,之后在给m个圆,这些圆可能会和原来的圆有所交集,计算开始的圆剩余区域的周长,不包括内部周长. 首先判定两圆关系,如果内含,直接加上圆的周长,如果相交 ...
- python字符串常用内建函数总结
自己总结一些常用字符串函数,理解比较粗糙 1.字符串内建函数-大小写转换函数 (1)str.capitalize Help on method_descriptor: capitalize(...) ...
- round函数在oracle和mysql中用法
1.oracle和mysql通用方法 #round(字段1,小数位数) 四舍五入select round('11.123456',4);结果:11.1235 2.mysql的另外2种保留小数位数方法# ...
- Flask中对MySQL的基本操作
在Flask-SQLAlchemy中,插入.修改.删除操作,均由数据库会话管理. 会话用 db.session 表示.在准备把数据写入数据库前,要先将数据添加到会话中然后调用 commit() 方法提 ...
- sqlachemy详解
实习期老大让我学Python...学了很久了好吗,不过确实对其中的一些原理性的东西还不够深入. 比如今天要说的sqlachemy,结合网上做些总结吧 ORM 全称 Object Relational ...
- CentOS 7.4使用yum源安装php7.2
1.如果之前已经安装我们先卸载一下 yum -y remove php* 2.由于linux的yum源不存在php7.x,所以我们要更改yum源 rpm -Uvh https://dl.fedorap ...
- 吐血分享:QQ群霸屏技术(初级篇)
QQ群,仿似一个冷宫;But,你真摒弃不起. 某人,坐拥2000多个2000人群,月收入10w+,此类人数少,皆因多年的沉淀,以形成完全的壁垒,难以企及的层次. 流量的分散,QQ群相对比较优质的地带, ...
- 模块导入应用settings的字符串
看django源码,感觉他的settings好高大上然后自己试试 以上是文件目录 email.py中代码 class Email: def send(self): print('发送email') M ...
- HDOJ 1176 免费馅饼(完全背包)
参考:https://blog.csdn.net/hhu1506010220/article/details/52369785 https://blog.csdn.net/enjoying_scien ...