题意:有k个人带着价值vi的礼物来,开m次门,每次在有t个人来的时候开门放进来p个人,所有人都来了之后再开一次门把剩下的人都放进来,每次带礼物价值高的人先进,价值相同先来先进,q次询问,询问第n个进来的人的名字。

解法:一道现场wa到死的模拟……拿set/map/priority_queue维护一下序列。赛后重写一遍……依旧wa到死……我只想说……

m可以为0

m可以为0

m可以为0啊!

orz……

代码:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long using namespace std; struct node
{
int id, val;
char name[205];
bool operator < (const node &tmp) const
{
if(val == tmp.val) return id < tmp.id;
return val > tmp.val;
}
}p[150005];
struct opendoor
{
int a, b;
bool operator < (const opendoor &tmp) const
{
return a < tmp.a;
}
}od[150005];
set <node> s;
int query[105];
int main()
{
int T;
while(~scanf("%d", &T))
{
while(T--)
{
s.clear();
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; i++)
{
scanf("%s%d", p[i].name, &p[i].val);
p[i].id = i;
}
for(int i = 0; i < m; i++)
scanf("%d%d", &od[i].a, &od[i].b);
sort(od, od + m);
int maxq;
for(int i = 0; i < q; i++)
{
scanf("%d", &query[i]);
maxq = max(maxq, query[i]);
}
vector <int> ans;
int cnt = 0;
for(int i = 1; i <= n && ans.size() < maxq; i++)
{
s.insert(p[i]);
while(od[cnt].a == i && cnt < m)//要在这里判一下……因为m为0时就会使用上一个样例的输入……所以初始化一下也是可以的……
{
for(int j = 0; j < od[cnt].b && !s.empty() && ans.size() < maxq; j++)
{
ans.push_back(s.begin() -> id);
s.erase(s.begin());
}
cnt++;
}
}
while(!s.empty() && ans.size() < maxq)
{
ans.push_back(s.begin() -> id);
s.erase(s.begin());
}
for(int i = 0; i < q; i++)
{
if(i) printf(" ");
cout << p[ans[query[i] - 1]].name;
}
puts("");
}
}
return 0;
}

  

HDU 5437 Alisha’s Party的更多相关文章

  1. hdu 5437 Alisha’s Party 优先队列

    Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...

  2. hdu 5437 Alisha’s Party 模拟 优先队列

    Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her f ...

  3. HDU 5437 Alisha’s Party (优先队列)——2015 ACM/ICPC Asia Regional Changchun Online

    Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her f ...

  4. 优先队列 + 模拟 - HDU 5437 Alisha’s Party

    Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. ...

  5. HDU 5437 Alisha’s Party (优先队列模拟)

    题意:邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每次都是礼物价值高的人先进.最后 ...

  6. HDU 5437 & ICPC 2015 Changchun Alisha's Party(优先队列)

    Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  7. HDU OJ 5437 Alisha’s Party 2015online A

    题目:click here 题意: 邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每 ...

  8. hdu 5437(优先队列模拟)

    Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  9. hdu 5437

    Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

随机推荐

  1. Maintainable HashCode and Equals Using Apache Commons

    Java hashCode and equals methods can be tricky to implement correctly. Fortunately, all majors IDEs ...

  2. [转]SQL Server建立应用程序安全性和程序角色

    转自:http://dev.yesky.com/450/7619450.shtml 2007-10-22 14:00 来源:论坛整理 作者:luolina 责任编辑:幽灵·yesky Microsof ...

  3. http://www.oschina.net/translate/elasticsearch-getting-started?cmp

    http://www.oschina.net/translate/elasticsearch-getting-started?cmp

  4. mac 下周期调度命令或脚本

    crontab 是在linux服务器上部署定时任务的方法 0 5 * * * /usr/bin/python /data/www/tools/mysql_backup.py cmd之前有5个项目要填, ...

  5. 李洪强iOS开发之OC语言description方法和sel

    OC语言description方法和sel 一.description方法 Description方法包括类方法和对象方法.(NSObject类所包含) (一)基本知识 -description(对象 ...

  6. EXCEL排序

    题目描述:     Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能.     对每个测试用例,首先输出1行“Case i:”,其中 i 是测试用例的编号(从1开始).随后在 N ...

  7. React 性能调优原理

    一.React影响性能的两个地方 二.调优原理

  8. java -version

  9. 修改linux终端命令行颜色

    进入修改:vim /root/.bashrc 1.PS1 要修改linux终端命令行颜色,我们需要用到PS1,PS1是Linux终端用户的一个环境变量,用来说明命令行提示符的设置.在终端输入命令:#s ...

  10. Intellij Idea 创建EJB项目入门(一)

    相关软件: 1.JBoss(jboss-as-7.1.1.Final):http://jbossas.jboss.org/downloads 2.Intellij IDEA 13.02 3.JDK 1 ...