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) ...
随机推荐
- 2014多校第一场A题 || HDU 4861 Couple doubi
题目链接 题意 : 有K个球,给你一个数P,可以求出K个值,(i=1,2,...,k) : 1^i+2^i+...+(p-1)^i (mod p).然后女朋友先取,再xp取,都希望赢,如果女朋友能赢输 ...
- 通过Calendar 类获取前一个月的第一天
SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd 00:00:00"); //获取到当前的时间 Cale ...
- 李洪强漫谈iOS开发[C语言-009] - C语言关键字
// // main.m // 04 - C语言关键字 // // Created by vic fan on 16/7/12. // Copyright © 2016年 李洪强. All r ...
- lintcode 中等题:minimum window substring 最小子串覆盖
题目 最小子串覆盖 给定一个字符串source和一个目标字符串target,在字符串source中找到包括所有目标字符串字母的子串. 样例 给出source = "ADOBECODEBANC ...
- jsp片段
转载自:http://blog.csdn.net/lovejavaydj/article/details/7293145 使用jspf 在开发中写jsp页面时,通常都要通过如下方式在jsp文件头部引入 ...
- eclipse安装插件的各种方法
做为当下最流行的开源IDE之一,Eclipse的一大优势就在于其无数优秀的插件.一个好的插件可以大大的提高我们的工作效率,学习如何安装Eclipse插件自然也是必修课了.下面介绍Eclipse插件的安 ...
- pinyin4j
最近在倒腾与搜索相关的拼音检查技术,顺便看了一下中文转拼音开源插件pinyin4j的源码,参考资料:http://blog.csdn.net/hfhwfw/archive/2010/11/23/603 ...
- (贪心5.2.1)UVA 10026 Shoemaker's Problem(利用数据有序化来进行贪心选择)
/* * UVA_10026.cpp * * Created on: 2013年10月10日 * Author: Administrator */ #include <iostream> ...
- cocos2dx 的基本框架
AppDelegate.h #ifndef _APP_DELEGATE_H_ #define _APP_DELEGATE_H_ #include "cocos2d.h" USING ...
- C#中控件的CheckState和Checked属性区别?
Checked 和CheckState都是检查控件选中状态,都能判断是否选中控件. 只是Checked 通过布尔判断(true & false): CheckState 通过枚举判断. che ...