HDU 4393 Throw nails
Throw nails
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1729 Accepted Submission(s): 538
annual school bicycle contest started. ZL is a student in this school.
He is so boring because he can't ride a bike!! So he decided to
interfere with the contest. He has got the players' information by
previous contest video. A player can run F meters the first second,
and then can run S meters every second.
Each player has a single
straight runway. And ZL will throw a nail every second end to the
farthest player's runway. After the "BOOM", this player will be
eliminated. If more then one players are NO.1, he always choose the
player who has the smallest ID.
In each case, the first line contains one integer n (1 <= n <= 50000), which is the number of the players.
Then
n lines follow, each contains two integers Fi(0 <= Fi <= 500), Si
(0 < Si <= 100) of the ith player. Fi is the way can be run in
first second and Si is the speed after one second .i is the player's ID
start from 1.
Huge input, scanf is recommended.
Huge output, printf is recommended.
c is the case number start from 1.
The
second line output n number, separated by a space. The ith number is
the player's ID who will be eliminated in ith second end.
Hint
The first case:
#include <cstdio>
#include <queue>
using namespace std; struct node{
int f,id;
bool operator<(const node& tmp)const
{
if(f != tmp.f) return f<tmp.f;
return id>tmp.id;
}
}; priority_queue<node> q[]; int main()
{
int t,n,cn = ;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(int i = ; i <= n; ++i){
node tmp;
int Si;
scanf("%d%d",&tmp.f,&Si);
tmp.id = i;
q[Si].push(tmp);
}
printf("Case #%d:\n",++cn);
for(int i = ; i <= n; ++i){
int res;
int maxdis = -;
int minid = 0x7fffffff;
for(int j = ; j <= ; ++j){
if(!q[j].empty()){
int dis = q[j].top().f+(i-)*j;
if(dis>maxdis || (dis == maxdis && q[j].top().id<minid)){
maxdis = dis;
minid = q[j].top().id;
res = j;
}
}
}
if(i != n)
printf("%d ",q[res].top().id);
else
printf("%d\n",q[res].top().id);
q[res].pop();
}
}
return ;
}
HDU 4393 Throw nails的更多相关文章
- hdu 4393 Throw nails(STL之优先队列)
Problem Description The annual school bicycle contest started. ZL is a student in this school. He is ...
- HDU 4393 Throw nails(优先队列)
优先队列的应用 好坑,好坑,好坑,重要的事情说三遍! #include<iostream> #include<cstdio> #include<cstring> # ...
- HDU 4393 Throw nails(贪心加模拟,追及问题)
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=115361#problem/D 题意大致是:给出最多50000个人,拥有最初速度 ...
- 【HDOJ】4393 Throw nails
水题,优先级队列. /* 4393 */ #include <iostream> #include <sstream> #include <string> #inc ...
- hdu4393 Throw nails(只用模拟前面500来次,后面根据速度、位置、id值排序即可)
...
- HDU 4573 Throw the Stones(动态三维凸包)(2013 ACM-ICPC长沙赛区全国邀请赛)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4573 Problem Description Remember our childhood? A fe ...
- G - Throw nails
来源hde4393 The annual school bicycle contest started. ZL is a student in this school. He is so boring ...
- 刷题总结——Throw nails(hdu4393)
题目: Problem Description The annual school bicycle contest started. ZL is a student in this school. H ...
- hdu 4393 优先队列
用优先队列储存每个人的初始距离和编号,每轮求出最快的人,然后pop掉 一开始想遍历队列的,后来发现队列没办法遍历,汗-_-! 题意,给几个第一秒冲出的距离和以后速度,求每秒后最前面人的编号,求完后最前 ...
随机推荐
- O2O模式
O2O即Online To Offline(在线离线/线上到线下) 是指将线下的商务机会与互联网结合,让互联网成为线下交易的前台,这个概念最早来源于美国.O2O的概念非常广 泛,既可涉及到线上,又可涉 ...
- 2337:[HNOI2011]XOR和路径 - BZOJ
昨天才做了一道高斯消元,一下要精度判断,一下又不要精度判断 主要是思路很重要 很容易想到每一个二进制位算一个概率,然后求和,设f[i]为走到从i走到n这一个二进制位为1的概率 f[i]:=∑{f[j] ...
- [转载]MongoDB优化的几点原则
.查询优化 确认你的查询是否充分利用到了索引,用explain命令查看一下查询执行的情况,添加必要的索引,避免扫表操作. .搞清你的热数据大小 可能你的数据集非常大,但是这并不那么重要,重要的是你的热 ...
- discuz微社区 始终显示“正在加载中”
使用DZ的tools工具一键关闭所有插件后,帮我排查了js冲突的问题,但是也带来了一系列后患: 云平台连“QQ互联”也失效了,之前云平台的各项业务已经不正常,无法开启关闭,提示“远程接口无法调用... ...
- ***CI异常记录到日志:CodeIgniter中设计一个全局exception hook
在CodeIgniter中,当发生异常时,经常要通知系统管理员,因此有必要在全局的高度上 捕捉异常,因此可以写一个hook, 比如在config目录的hook.php中,加入: $hook['pre_ ...
- ***phpredis扩展安装总结
phpredis扩展安装总结:PHP扩展安装在[root@iZ254lfyd6nZ lampp]# cd include 目录下创建一个目录phpredis下载扩展:wget https://gith ...
- 解决ListView 跟ScroolView 共存 listItem.measure(0, 0) 空指针
在网上找到ListView 和ScroolView 共存的方法无非是给他每个listview 重新增加高度,但是android 的设计者始终认为这并不是一种好的实现方法.但是有的时候有必须要用这种蛋疼 ...
- linux MySQL安装配置
执行下面的命令初始化授权表: ./scripts/mysql_install_db --user=mysql
- PowerDesigner15(16)在生成SQL时报错Generation aborted due to errors detected during the verification of the mod
1.用PowerDesigner15建模,在Database—>Generate Database (或者用Ctrl+G快捷键)来生产sql语句,却提示“Generation aborted d ...
- Django Navi 重用
代码来自这里: base.html <html> <head>...</head> <body> ... {% block nav %} <ul ...