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掉 一开始想遍历队列的,后来发现队列没办法遍历,汗-_-! 题意,给几个第一秒冲出的距离和以后速度,求每秒后最前面人的编号,求完后最前 ...
随机推荐
- Python拷贝及多进程与类的问题
最近写python写的尤其不顺利,更多的debug,逐渐的深入,产出却比较少.应该是个瓶颈期,坚持坚持,厚着脸皮也要坚持下去. 0x00 拷贝问题 程序中涉及到多进程和协程,大致的模型是开了2+个进程 ...
- jquery全局加载函数的几种方式;
1.使用javascript方式(function(){})(); 2.使用jQuery(function($) {}); 3.使用$(document).ready(function(){}); 其 ...
- mysql日志详细解析 [转]
原文出处:http://pangge.blog.51cto.com/6013757/1319304 MySQL日志: 主要包含:错误日志.查询日志.慢查询日志.事务日志.二进制日志: 日志是mysql ...
- CSS两列及三列自适应布局方法整理
布局 自适应 两列 三列 在传统方法的基础上加入了Flex布局并阐述各方法的优缺点,希望对大家有所帮助.先上目录: 两列布局:左侧定宽,右侧自适应 方法一:利用float和负外边距 方法二:利用外边距 ...
- 反射自动填充model
public static T FillModel<T>(DataRow dr) { ) return default(T); T model = Activator.CreateInst ...
- js解决checkbox全选和反选的问题
function SelectAll() { var checkboxs=document.getElementsByName("chk_list"); for (var i=0; ...
- XoftSpy 4.13的注册算法分析
[标题]XoftSpy 4.13的注册算法分析 [作者]forever[RCT] [语言]VC [工具]ida4.6,ollydbg1.1 [正文] 这个软件的算法很简单,正好拿来做逆向分 ...
- 算法导论_ch2
Ch2算法基础 whowhoha@outlook.com 2.1 插入排序 输入:n个数的一个序列〈a1,a2,…,an〉. 输出:输入序列的一个排列〈a′1,a′2,…,a′n〉,满足a′1≤a′2 ...
- SaaS系列介绍之九: SaaS营销模式分析
1 配置模式 中国企业很多是人治,管理弹性非常大,公司的政策经常变化,管理流程.业务变化也非常大,发展也非常快;一个公司今年是10个人,明年是100个人,后年可能是1000人.管理机制.方法处于经常变 ...
- SQL Server中的分页
sqlserver2000时的分页思路 .分页查询时,首先将数据排序 select * from MyStudent order by fid desc .取第一页数据 * from MyStuden ...