HDU 5437 Alisha’s Party
题意:有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的更多相关文章
- hdu 5437 Alisha’s Party 优先队列
Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...
- hdu 5437 Alisha’s Party 模拟 优先队列
Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her f ...
- 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 ...
- 优先队列 + 模拟 - HDU 5437 Alisha’s Party
Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. ...
- HDU 5437 Alisha’s Party (优先队列模拟)
题意:邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每次都是礼物价值高的人先进.最后 ...
- 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) ...
- HDU OJ 5437 Alisha’s Party 2015online A
题目:click here 题意: 邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每 ...
- hdu 5437(优先队列模拟)
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- hdu 5437
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
随机推荐
- Bad configuration option localCommand
command-line: line 0: Bad configuration option: PermitLocalCommand 2011-12-08 14:04:54 标签:Bad confi ...
- recursion lead to out of memory
There are two storage areas involved: the stack and the heap. The stack is where the current state o ...
- POJ 1795
DNA Laboratory Time Limit: 5000MS Memory Limit: 30000K Total Submissions: 1425 Accepted: 280 Des ...
- POJ2251Dungeon Master
http://poj.org/problem?id=2251 题意 : 就是迷宫升级版,从以前的一个矩阵也就是一层,变为现在的L层," . "是可以走,但是“#”不可以走,从S走到 ...
- 搭建网站 discuzx ecshop php
1.http://www.comsenz.com/downloads/install/discuzx下载
- 欧拉工程第72题:Counting fractions
题目链接:https://projecteuler.net/problem=72 真分数;n/d 当d ≤ 1,000,000时候的真分数有多少个 public class P72{ void run ...
- leetcode 4 : Median of Two Sorted Arrays 找出两个数组的中位数
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...
- 转:samba 启动和重新启动 以及在虚拟系统和实际系统怎么实现软件交换
转自:http://blog.csdn.net/zwhfyy/article/details/1605151 启动 smb start 重新启动 root 用户登陆 CHQ_WEB:/etc/init ...
- Linux 2.4.x内核软中断机制
http://www.ibm.com/developerworks/cn/linux/kernel/interrupt/ 软中断概况 软中断是利用硬件中断的概念,用软件方式进行模拟,实现宏观上的异步执 ...
- Unix编程之size_t、ssize_t
http://blog.csdn.net/lalor/article/details/7426184 首先,我非常肯定以 及确定的告诉你ssize_t是有符号整型,在32位机器上等同与int,在64位 ...