Alisha’s Party
Alisha’s Party
Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1815 Accepted Submission(s): 487
Each time when Alisha opens the door, she can decide to let p people enter her castle. If there are less than p people in the lobby, then all of them would enter. And after all of her friends has arrived, Alisha will open the door again and this time every friend who has not entered yet would enter.
If there are two friends who bring gifts of the same value, then the one who comes first should enter first. Given a query n Please tell Alisha who the n−th person to enter her castle is.
In each test case, the first line contains three numbers k,m and q separated by blanks. k is the number of her friends invited where 1≤k≤150,000. The door would open m times before all Alisha’s friends arrive where 0≤m≤k. Alisha will have q queries where 1≤q≤100.
The i−th of the following k lines gives a string Bi, which consists of no more than 200 English characters, and an integer vi, 1≤vi≤108, separated by a blank.Bi is the name of the i−th person coming to Alisha’s party and Bi brings a gift of value vi.
Each of the following m lines contains two integers t(1≤t≤k) and p(0≤p≤k) separated by a blank. The door will open right after the t−th person arrives, and Alisha will let p friends enter her castle.
The last line of each test case will contain q numbers n1,...,nq separated by a space, which means Alisha wants to know who are the n1−th,...,nq−th friends to enter her castle.
Note: there will be at most two test cases containing n>10000.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm> using namespace std; #define maxn 150008
char name[maxn][]; struct node
{
int v, id;
bool operator < (const node &t)const
{
if(v == t.v)
return id > t.id;
return v < t.v;
}
}p[maxn]; struct people
{
int t, p;
bool operator < (const people &k)const
{
return t < k.t;
}
}a[maxn]; int cnt[maxn]; int main()
{
int c, k, m, q, s, g, z;
scanf("%d", &c); while(c--)
{
g = ;
s = ;
priority_queue<node> Q;
scanf("%d%d%d", &k, &m, &q);
for(int i = ; i < k; i++) // 关系全让 下标 i 联系~
{
scanf("%s", name[i]);
scanf("%d", &p[i].v);
p[i].id = i;
}
for(int i = ; i < m; i++)
scanf("%d %d", &a[i].t, &a[i].p);
sort(a, a+m); // 坑点,输入的当第几个人到的开门不按顺序,要排序^^……^
for(int i = ; i < m; i++)
{
for(; s < a[i].t; s++)
Q.push(p[s]);
while(Q.size() && a[i].p)
{
node u = Q.top();
Q.pop();
cnt[g++] = u.id;
a[i].p--;
}
}
for(; s < k; s++)
Q.push(p[s]); // m次开门后如果还有人没进,一次依次进去
while(Q.size())
{
node u = Q.top();
Q.pop();
cnt[g++] = u.id;
}
while(q--)
{
scanf("%d", &z); if(q >= )
printf("%s ", name[cnt[z]]);
else
printf("%s\n", name[cnt[z]]);
}
}
return ;
}
Alisha’s Party的更多相关文章
- 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 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...
- HDU5437 Alisha’s Party (优先队列 + 模拟)
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- Alisha’s Party(队列)
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- Alisha’s Party (HDU5437)优先队列+模拟
Alisha 举办聚会,会在一定朋友到达时打开门,并允许相应数量的朋友进入,带的礼物价值大的先进,最后一个人到达之后放外面的所有人进来.用优先队列模拟即可.需要定义朋友结构体,存储每个人的到达顺序以及 ...
- Alisha's Party
Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- 优先队列 + 模拟 - HDU 5437 Alisha’s Party
Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让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) ...
随机推荐
- django中间件(获取请求ip)
def simple_middleware(get_response): # 此处编写的代码仅在Django第一次配置和初始化的时候执行一次. print('1----django启动了') def ...
- unigui 服务器 是否显示 程序窗口
unigui 服务器 是否显示 程序窗口 servermodule 窗体的这个standaloneserver属性 为false 时 显示窗体. 为true 时 不显示窗体. 哈哈
- struts2 基础5 OGNL、标签、四大域、默认拦截器说明
OGNL表达式 OGNL:对象导抗图语言 OGNL表达式是一个上下文的概念,上下文Map结构 OGNL表达式需要使用#标注命名空间.访问上下文(Context)中的对象需要使用#符号标注命名空间,如# ...
- C++[Tarjan求点双连通分量,割点][HNOI2012]矿场搭建
最近在学图论相关的内容,阅读这篇博客的前提是你已经基本了解了Tarjan求点双. 由割点的定义(删去这个点就可使这个图不连通)我们可以知道,坍塌的挖煤点只有在割点上才会使这个图不连通,而除了割点的其他 ...
- UDP信号驱动IO
SIGIO信号 信号驱动式I/O不适用于TCP套接字, 因为产生的信号过于频繁且不能准确判断信号产生的原因. 设置信号驱动需把sockfd的非阻塞与信号驱动属性都打开 server sockfd单独提 ...
- promise 封装 axios
/*axios({ method:"get", url:"./data.json", data:{ id:10 } }).then((res)=>{ co ...
- 编写 Chrome 扩展——contextMenus 的快捷创建
1 写在前面 最近使用 typescript 与 angular 编写 chrome 扩展, 对繁复的 contextMenus 创建步骤进行了提炼,并总结一个类 2 重构思路 2.1 一般方法 在编 ...
- jsp对象 指令 动作
转载来源:https://blog.csdn.net/u010897406/article/details/49618413 jsp九大内置对象:1>out 向客户端输出数据,字节流.如out. ...
- H-Updating a Dictionary (模拟)
In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, a ...
- c++知识点总结3
http://akaedu.github.io/book/ week1 引用:相当于变量的别名.下面r和n就相当于同一回事 ; int &r=n; 引用做函数参数: void swap(int ...