题目:

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. ElasticSearch High Level REST API【7】聚合

    获取平均值聚合示例,最大值.最小值.求和类似 public void aggregation(){ RestHighLevelClient client = elasticClient.getRest ...

  2. Jenkins搭建CI/CD

    所需Jenkins插件: Maven Integration pluginPublish Over SSHSSH plugin 1.配置全局工具 配置JDK: 配置Git: 配置maven: 2.创建 ...

  3. python json.dumps raise TypeError(repr(o) + " is not JSON serializable") TypeError: 0 is not JSON serializable

    出错如题. 这个问题有可能是因为python的json.dumps没法识别dump内容里的某些数据类型导致的.我的问题是因为dict中含有numpy.int64,numpy.float等类型导致的,需 ...

  4. 封装动态数组类Array

    功能: 1.增.删.改.查 2.扩容.缩容 3.复杂度分析 4.均摊复杂度 5.复杂度震荡 分析动态数组的时间复杂度: 分析resize的时间复杂度: public class Array<E& ...

  5. spring-mvc.xml的定时器配置

    <!-- 设置时间 --> <bean id="myJobTrigger" class="org.springframework.scheduling. ...

  6. HDU3853 概率DP

    LOOPS   Homura wants to help her friend Madoka save the world. But because of the plot of the Boss I ...

  7. SGU495 概率DP

    Kids and Prizes ICPC (International Cardboard Producing Company) is in the business of producing car ...

  8. 在WebAPI中调用其他WebAPI

    client.BaseAddress = new Uri("http://xxx.xxx.xx.xx:xxxx/); client.DefaultRequestHeaders.Accept. ...

  9. HyperLedger Fabric 1.4 区块链技术定义(2.1)

    区块链技术指使用点对点传输.共识机制.加密算法等技术,保证分布式数据库区块写入链中数据的一致性,达到去中心化和不可篡改的目的.       区块链就是一种特殊的分布式数据库,使用现有的各种成熟的技术, ...

  10. 笔记-reactor pattern

    笔记-reactor pattern 1.      reactor模式 1.1.    什么是reactor模式 The reactor design pattern is an event han ...