题目:

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. 介绍hadoop中的hadoop和hdfs命令

    有些hive安装文档提到了hdfs dfs -mkdir ,也就是说hdfs也是可以用的,但在2.8.0中已经不那么处理了,之所以还可以使用,是为了向下兼容. 本文简要介绍一下有关的命令,以便对had ...

  2. 图像压缩函数imagecopyresampled

    <?php //制作缩略图.图像压缩 //参数1:目的地图像资源(通常指的是画布资源) $dst_image = imagecreatetruecolor(100, 100); $color = ...

  3. thinkphp centos7 报class POD not found

    没有安装PDO yum install php70w-pdo yum install php70w-mysqlnd 两条命令搞定

  4. PLC状态机编程第三篇-RS信号处理

    我们今天简要介绍RS指令在状态机中怎么处理的.有些设备按下停止按钮后,没有马上停止,而是到原点后才停止,那么这种情况在状态机中如何表示呢?我们以案例说明之,下面是我们的控制描述. 控制描述 小车从左位 ...

  5. Ubuntu 14.10 配置JDK + J2EE

    本文仅作为本人在Ubuntu 14.10下安装JDK + J2EE的一个记录: 安装JDK 从Oracle的官网下载jdk-7u75-linux-x64.tar.gz 将jdk-7u75-linux- ...

  6. NetCore log4net 集成以及配置日志信息不重复显示或者记录

    NetCore log4net 集成,这是一个很常见而且网上大批大批的博文了,我写这个博文主要是为了记录我在使用过程中的一点小收获,以前在使用的过程中一直没有注意但是其实网上说的不清不楚的问题. 官方 ...

  7. VHDL语法入门学习第一篇

    1. 现在先遇到一个VHDL的语法问题,以前没用过VHDL,现在要去研究下,进程(PROCESS) 进程内部经常使用IF,WAIT,CASE或LOOP语句.PROCESS具有敏感信号列表(sensit ...

  8. vue理解$nextTick

    首先要明确: Vue 实现响应式并不是数据发生变化之后 DOM 立即变化,而是按一定的策略进行 DOM 的更新. $nextTick 是在下次 DOM 更新循环结束之后执行延迟回调,在修改数据之后使用 ...

  9. 剑指Offer - 九度1387 - 斐波那契数列

    剑指Offer - 九度1387 - 斐波那契数列2013-11-24 03:08 题目描述: 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项.斐波那契数列的定义如下: ...

  10. 【Neural Network】林轩田机器学习技法

    首先从单层神经网络开始介绍 最简单的单层神经网络可以看成是多个Perception的线性组合,这种简单的组合可以达到一些复杂的boundary. 比如,最简单的逻辑运算AND  OR NOT都可以由多 ...