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) ...
随机推荐
- MVC 源码系列之控制器执行(二)
## 控制器的执行 上一节说道Controller中的ActionInvoker.InvokeAction public virtual bool InvokeAction(ControllerCon ...
- python接口自动化:调试接口的代码(无token情况下)
实现代码如下: #接口调试 import requests,time class api_demo1: def __init__(self,RequestWay,url,data): self.s=r ...
- linux挂载磁盘以及扩容主分区
新买的服务器,如果系统安装操作不当,可能会由于系统主分区过小,后期安装软件过多就会导致软件无法正常运行的问题,如果不做系统格式化,就需要通过购买新的硬盘来进行挂载和扩容主分区以解决问题.本文主要介绍l ...
- js json中的时间转换格式
//根据json中的日期格式,转换成yyyy-mm-dd HH:mm:ss function ChangeDateFormat(cellval) { var date = new Date(parse ...
- 实验报告2&&第四周课程总结
实验报告: 写一个名为Rectangle的类表示矩形.其属性包括宽width.高height和颜色color,width和height都是double型的,而color则是String类型的.要求该类 ...
- SpringBoot使用webservice
Pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spr ...
- [Python3] 020 借函数,谈一谈变量的作用域
目录 1. 概述 2. 分类 3. 变量的作用范围 少废话,上例子 4. 将局部变量提升为全局变量 少废话,上例子 5. 内建函数 globals() 与 locals() 少废话,上例子 6. 邪恶 ...
- oracle-第N篇加强专题
1.Oracle数据库日期类型 1>日期的比较 2>日期格式化 2.Oracle字符串类型 1>常用函数
- vs2015上编译QT程序的环境搭建
下载相对应版本的QT(以QT5.7.0为例),进入网站http://download.qt.io/archive/qt/5.7/5.7.0/,下载MSVC版本QT,我的系统是64位,VS版本是2015 ...
- AtCoder Beginner Contest 134-E - Sequence Decomposing
(https://atcoder.jp/contests/abc134/tasks/abc134_e) 题意:找出最小个数的最长上升子序列 思路:找出最长上升子序列的最小个数,只需要找出每个最小上升子 ...