题目:

Problem Description

The 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.

Input

In the first line there is an integer T (T <= 20), indicates the number of test cases.
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.

Hint

Huge input, scanf is recommended.
Huge output, printf is recommended.

Output

For each case, the output in the first line is "Case #c:".
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.

Sample Input

2
3
100 1
100 2
3 100
5
1 1
2 2
3 3
4 1
3 4

Sample Output

Case #1:
1 3 2
Case #2:
4 5 3 2 1

Hint

Hint
The first case:

1st Second end
Player1 100m (BOOM!!)
Player2 100m
Player3 3m

2nd Second end
Player2 102m
Player3 103m (BOOM!!)

3rd Second end
Player2 104m (BOOM!!)

Source

 

题目:

  这道题其实有一个很nb的做法··这里就不提了··网上都有··

  首先想到这道题由于严格按淘汰顺序输出肯定要模拟淘汰的过程···但肯定不会是纯模拟···

  看到SF偏小,然后由每次淘汰最大我们考虑消除FS中的某个影响··从而利用单调性快速求出最大值··

  是不是和NOIP2016蚯蚓很像?

  我们将S(因为S<=100)相等的车子塞进同一个有限队列中··按第一关键字F,第二关键字标号排序,然后每次模拟时比较每个队列的对首元素即可····

代码:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cctype>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
inline int R(){
char c;int f=;
for(c=getchar();c<''||c>'';c=getchar());
for(;c<=''&&c>='';c=getchar()) f=(f<<)+(f<<)+c-'';
return f;
}
priority_queue< pair<int,int> > que[];
int T,n;
int main()
{
//freopen("a.in","r",stdin);
T=R();
for(int a=;a<=T;a++)
{
printf("Case #%d:\n",a);
n=R();int f,s,lim=;
for(int i=;i<=n;i++) f=R(),s=R(),lim=max(lim,s),que[s].push(make_pair(f,-i));
for(int t=;t<n;t++){
int ans,maxx=-,v;
for(int i=;i<=lim;i++){
if(que[i].empty()) continue;
int f=que[i].top().first,id=-que[i].top().second;
if(f+i*t>maxx||(f+i*t==maxx&&id<ans)){
maxx=f+i*t;ans=id,v=i;
}
}
if(t!=n-) printf("%d ",ans);
else printf("%d",ans);
que[v].pop();
}
putchar('\n');
}
return ;
}

刷题总结——Throw nails(hdu4393)的更多相关文章

  1. hdu4393 Throw nails(只用模拟前面500来次,后面根据速度、位置、id值排序即可)

                                                                                                         ...

  2. leetcode刷题--两数之和(简单)

    一.序言 第一次刷leetcode的题,之前从来没有刷题然后去面试的概念,直到临近秋招,或许是秋招结束的时候才有这个意识,原来面试是需要刷题的,面试问的问题都是千篇一律的,只要刷够了题就差不多了,当然 ...

  3. leecode刷题(8)-- 两数之和

    leecode刷题(8)-- 两数之和 两数之和 描述: 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标. 你可以假设每种输 ...

  4. 牛客网Java刷题知识点之Java 集合框架的构成、集合框架中的迭代器Iterator、集合框架中的集合接口Collection(List和Set)、集合框架中的Map集合

    不多说,直接上干货! 集合框架中包含了大量集合接口.这些接口的实现类和操作它们的算法. 集合容器因为内部的数据结构不同,有多种具体容器. 不断的向上抽取,就形成了集合框架. Map是一次添加一对元素. ...

  5. leetcode 刷题记录(java)-持续更新

    最新更新时间 11:22:29 8. String to Integer (atoi) public static int myAtoi(String str) { // 1字符串非空判断 " ...

  6. 基于Typescript和Jest刷题环境搭建与使用

    写在前面 前几个月在公司用vue3和ts写项目,想巩固一下基础,于是我想起了去年基于JavaScript和Jest搭建的刷题环境,不如,给它搞个加强版,结合Typescript和Jest 搞一个刷题环 ...

  7. LeetCode刷题系列

    LeetCode 我们工作面试和提高自身数据结构和算法能力的时候往往需要刷刷题,我选择LeetCode是通过一个留学论坛了解的.专业,覆盖语种全面. 提前说说刷题的心得: 尽量手写代码,少使用IDE的 ...

  8. ife任务刷题总结(一)-css reset与清除浮动

    本文同时发布于本人的个人网站www.yaoxiaowen.com 百度创办的前端技术学院,是一个面向大学生的前端技术学习平台.虽然只有大学生才有资格报名,提交代码进行比赛排名.但是这并不妨碍我们这些初 ...

  9. 刷题ING...

    我用codeVS刷题.. 努力准备!!

随机推荐

  1. vc导出调用dll的两种方式

    一.stdcall 1. #define  DLLEXPORT _declspec(dllexport) _stdcall, int DLLEXPORT func(const char *peer,u ...

  2. 【ACM之行】◇第一站◇ 2018HDU多校赛总结

    ◇第一站◇ 2018HDU多校赛 十场多校赛下来,也算是给一个初中生开了眼界……看着清华一次次AK(默默立下flag),看着自己被同校的高中生完虐,一个蒟蒻只能给dalao们垫脚

  3. ethereum(以太坊)(五)--Bool

    pragma solidity ^0.4.0; contract Bool{ uint num1 = 100; uint num2 = 200; bool _c = true; // &&am ...

  4. scrapy--BeautifulSoup

    BeautifulSoup官方文档:https://beautifulsoup.readthedocs.io/zh_CN/latest/#id8 太繁琐的,精简了一些自己用的到的. 1.index.h ...

  5. FreeBSD--常用命令

    FreeBSD常用命令   查看网络流量 a.systat -if 1 (1表示1s刷新屏幕一次) b.netstat 1 # Traffic 流量 peak 峰值 average 平均值 查看进程p ...

  6. python__系统 : 线程

    线程之间,全局变量可以共享,但是局部变量依然是不共享的,线程的创建方式: threading.Thread(),还可以定义一个类继承Thread,重写他的run方法,具体和进程的写法一样. 那么,线程 ...

  7. C语言指针篇(一)指针与指针变量

    指针 1. 什么是指针?    2. 指针可不可怕? 3. 指针好不好玩? 4. 怎么学好指针?     C语言是跟内存打交道的语言,指针就是内存地址.指针无处不在,指针并不可怕,相反,等你学到一定程 ...

  8. Android面试收集录 Android入门

    1.Android的特点有哪些? 编程语言是Java或Kotlin,Android中的Java字节码是允许在Dalvik虚拟机上的 支持4大组件 Android内置了WebKit核心的浏览器,支持H5 ...

  9. linux上Kettle定时执行(转换的单步执行,job的单步执行,环境变量,kettle定时功能,效率问题等)转自(http://blog.csdn.net/feng19821209/article/details/5800960)

    1,Kettle跨平台使用.    例如:在AIX下(AIX是IBM商用UNIX操作系统,此处在LINUX/UNIX同样适用),运行Kettle的相关步骤如下:    1)进入到Kettle部署的路径 ...

  10. Kafka安装和常用操作命令

    Kafka安装: 下载kafka_2.10-0.8.2.1 1.关闭防火墙 2.修改配置文件  server.properties broker.id=1log.dirs= /usr/kafka_2. ...