Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2650    Accepted Submission(s): 722 Problem Description Princess Alisha invites her friends to come to her birthday party. Each o…
点击打开链接 可能出现的问题: 1.当门外人数不足p人时没有判断队列非空,导致RE. 2.在m次开门之后最后进来到一批人没有入队. 3.给定的开门时间可能是打乱的,需要进行排序. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<cstring> #include<iostream> #include<vector>…
Alisha 举办聚会,会在一定朋友到达时打开门,并允许相应数量的朋友进入,带的礼物价值大的先进,最后一个人到达之后放外面的所有人进来.用优先队列模拟即可.需要定义朋友结构体,存储每个人的到达顺序以及携带礼品价值,并重载<运算符.然后模拟即可. #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<algorithm> #include…
题意:邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每次都是礼物价值高的人先进.最后给出q个数,表示要输出第ni个进来的人的名字. 析:其实这就是一个模拟题,很容易知道是优先队列模拟,不能set,会超时,反正我是超时了,然后就一步步的模拟就好了,注意它给的时间可能不是按顺序,要排序,在比赛时我就没排序,一直WA.... 代码如下: #include <cstdio> #inclu…
Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4389    Accepted Submission(s): 1121 Problem Description Princess Alisha invites her friends to come to her birthday party. Each…
Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her friends will bring a gift of some value v, and all of them will come at a different time. Because the lobby is not large enough, Alisha can only let a…
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main() { int n; scanf("%d",&n); int t; scanf("%d",&t); ; i <= n; i++){ int v; scanf("%d",&v); q.push(v); } ; while(…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5437 题意:公主有k个朋友来参加她的生日party,每个人都会带价值为v[i]的礼物过来,在所有人到齐之前公主会打开大门m次,每次开门就是在第t个人到来之后,然后让p个人进入大厅,如果当前人数不足p人,则让所有人都进去,最后在所有人都来到门口时,再次打开门,让剩下所有的人都进入大厅:当然选择礼物价值大的先进入,如果两个人的礼物价值相等,则先来的先进,现在有q个问题,问第ni个进入大厅的人是谁: 我们…
Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. 给出开门的操作:当第ti个人来时,打开门让pi个人进入. q个询问,对于每个询问qi,你需要回答第qi个进入房间的人的名字. analyse: 维护一个优先队列,模拟就行. 需要注意,由于priority_queue对重载运算符貌似会出错,所以使用multiset来做priority_queue使用…
Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her friends will bring a gift of some value v, and all of them will come at a different time. Because the lobby is not large enough, Alisha can only let a…