比赛的时候虽然考虑到没门的情况,但是写了几组都能过,就没想了,23333,差一行代码就能A,遗憾~~

 #include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
#define pb(a) push_back(a)
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt,cnt,k;
struct Node
{
int id;
char s[];
int v;
friend bool operator<(Node a,Node b)
{
if(a.v==b.v)
{
return a.id>b.id;
}
return a.v<b.v;
}
}node[MAXN];
struct Node2
{
int b,c;
void in()
{
scanf("%d%d",&b,&c);
}
}node2[MAXN];
int ans[MAXN];
void fun()
{
int i;
priority_queue<Node> q;
Node now;
int sum=,tot=;
for(i=;i<=k;i++)
{
q.push(node[i]);
if(q.size()+sum==node2[tot].b)
{
for(int j=;j<node2[tot].c&&!q.empty();j++)
{
now=q.top();
q.pop();
ans[sum++]=now.id;
}
tot++;
}
}
while(!q.empty())
{
now=q.top();
q.pop();
ans[sum++]=now.id;
}
}
bool cmp(Node2 aa,Node2 bb)
{
return aa.b<bb.b;
}
int main()
{
int i,j,ca=,q;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
scanf("%d",&tt);
while(tt--)
{
scanf("%d%d%d",&k,&m,&q); for(i=;i<=k;i++)
{
scanf("%s%d",&node[i].s,&node[i].v);
node[i].id=i;
}
node2[].b=-;
for(i=;i<m;i++)
{
node2[i].in();
}
sort(node2,node2+m,cmp);
fun();
int qq;
for(i=;i<q;i++)
{
scanf("%d",&qq);
qq--;
if(i==)
{
printf("%s",node[ans[qq]].s);
continue;
}
printf(" %s",node[ans[qq]].s);
}
printf("\n");
} }

hdu 5437 优先队列+模拟 **的更多相关文章

  1. hdu 5437(优先队列模拟)

    Alisha’s Party Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  2. HDU 5437 Alisha’s Party (优先队列模拟)

    题意:邀请k个朋友,每个朋友带有礼物价值不一,m次开门,每次开门让一定人数p(如果门外人数少于p,全都进去)进来,当最后所有人都到了还会再开一次门,让还没进来的人进来,每次都是礼物价值高的人先进.最后 ...

  3. Alisha’s Party (HDU5437)优先队列+模拟

    Alisha 举办聚会,会在一定朋友到达时打开门,并允许相应数量的朋友进入,带的礼物价值大的先进,最后一个人到达之后放外面的所有人进来.用优先队列模拟即可.需要定义朋友结构体,存储每个人的到达顺序以及 ...

  4. Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)

    优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...

  5. hdu 5437 Alisha’s Party 模拟 优先队列

    Problem Description Princess Alisha invites her friends to come to her birthday party. Each of her f ...

  6. 优先队列 + 模拟 - HDU 5437 Alisha’s Party

    Alisha’s Party Problem's Link Mean: Alisha过生日,有k个朋友来参加聚会,由于空间有限,Alisha每次开门只能让p个人进来,而且带的礼物价值越高就越先进入. ...

  7. hdu 5437 Alisha’s Party 优先队列

    Alisha’s Party Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/contests/contest_sh ...

  8. 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 ...

  9. 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) ...

随机推荐

  1. Oracle占用8080端口问题的解决

    可能在本地同时安装过Tomcat和Oracle的人都会知道,安装完Oracle后,会发现Tomcat的8080端口已经被Oracle占用了. 完全安装Oracle数据库后,当我们访问8080端口时,会 ...

  2. SSM 集成的两个配置文件

    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> < ...

  3. Shell 读取文本内容

    在Linux中有很多方法逐行读取一个文件的方法,其中最常用的就是下面的脚本里的方法,而且是效率最高,使用最多的方法.为了给大家一个直观的感受,我们将通过生成一个大的文件的方式来检验各种方法的执行效率. ...

  4. 手记-数学分析(高等数学)中有关算法效率的公式列举(O,Θ,Ω)

      权当数据结构与算法分析的学习手记     系数为一的幂级数部分和公式 ∑ n2 = 12 + 22 + 32 + ... + n2 = n(n+1)(2n+1)/6 = O(n3) ∑ n3 =  ...

  5. 1.nodejs权威指南--基础知识

    1. 基础知识 1.1 全局作用域及函数 1.1.1 全局作用域 在nodejs中,定义了一个global对象,代表nodejs中的全局命名空间,任何全局变量.函数或对象都是该对象的一个属性值 1.1 ...

  6. MySQL 5.6 Threadpool(优先队列)介绍及性能测试【转】

    本文来自:http://www.gpfeng.com/?p=540&utm_source=tuicool&utm_medium=referral 背景介绍 MySQL常用(目前线上使用 ...

  7. nyoj19_排列

    擅长排列的小明 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想 ...

  8. LeetCode 283 Move Zeros

    Problem: Given an array nums, write a function to move all 0's to the end of it while maintaining th ...

  9. ios NSLayoutConstraint

    为了让我们的应用在不同尺寸的屏幕下都能 “正常”的表示,我们尽量不要把数据写死.大多数可视元素都是一个矩形区域,当然这个矩形区域有坐标的,我们有了这个区域坐标就能确定可视元素的现实位置了.但是ipho ...

  10. linux日常易忘指令

    1.编辑全局指令 进入~/.bash_profile 增加"exprot +(启动文件的地址)" source ~/.bash_profilr(刷新) 2.修改mysql密码 my ...