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掉 一开始想遍历队列的,后来发现队列没办法遍历,汗-_-! 题意,给几个第一秒冲出的距离和以后速度,求每秒后最前面人的编号,求完后最前 ...
随机推荐
- 灵光乍现,lua数据绑定
MVVM的核心就是数据驱动,数据驱动的核心就是数据绑定. 我一直在思考,如何使用lua做一个数据绑定的功能,仔细思考一下,数据绑定需要做到的功能很简单,就是当一个数据改变时,能主动回调一个或多个函数就 ...
- 泛形集合List<T>
public class Person { /// <summary> /// 姓名 /// </summary> private string name; public st ...
- Java内存区域与内存溢出异常(二)
了解Java虚拟机的运行时数据区之后,大致知道了虚拟机内存的概况,内存中都放了些什么,接下来将了解内存中数据的其他细节,如何创建.如何布局.如何访问.这里虚拟机以HotSpot为例,内存区域以Java ...
- dive into python 读笔(2)
chapter 4 自省, summary: # 用可选和命名参数定义和调用函数 # 用 str 强制转换任意值为字符串形式 # 用 getattr 动态得到函数和其它属性的引用 # 扩展列表解析语法 ...
- sql shard/partition
sql http://www.infoq.com/news/2011/02/SQL-Sharding/ http://channel9.msdn.com/Shows/Data-Exposed/SqlD ...
- Automotive Security的一些资料和心得(1):Security Engineering
陆续更新一些最近在Automotive Security方面的资料和心得. 1. Overview 1.1. Software Engineering Process PLC-Phases: Intr ...
- 1050 棋盘染色 2 - Wikioi
题目描述 Description 有一个5*N的棋盘,棋盘中的一些格子已经被染成了黑色,你的任务是对最少的格子染色,使得所有的黑色能连成一块. 输入描述 Input Description 第一行一个 ...
- 839. Optimal Marks - SPOJ
You are given an undirected graph G(V, E). Each vertex has a mark which is an integer from the range ...
- 团体程序设计天梯赛-练习集L2-003. 月饼
L2-003. 月饼 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 月饼是中国人在中秋佳节时吃的一种传统食品,不同地区有许多不 ...
- python的web压力测试工具-pylot安装使用
http://blog.csdn.net/chenggong2dm/article/details/10106517 pylot是python编写的一款web压力测试工具.使用比较简单.而且测试结果相 ...