比赛的时候虽然考虑到没门的情况,但是写了几组都能过,就没想了,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. Hibernate 多对多关联映射, 中间表加查询条件

    package com.coracle.yk.xpo.po.base; import java.util.Date; import java.util.HashSet; import java.uti ...

  2. intellij Idea快捷键

    CTRL+ALT+O  优化导入的类和包 Alt + Center  导入类,实现接口 CTRL+N   查找类CTRL+SHIFT+N  查找文件CTRL+SHIFT+ALT+N 查找类中的方法或变 ...

  3. 升级centos内核到最新版本

    root权限执行: rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/ ...

  4. C语言宏定义时#(井号)和##(双井号)的用法1

    #在英语里面叫做 pound 在C语言的宏定义中,一个#表示字符串化:两个#代表concatenate 举例如下: #include <iostream> void quit_comman ...

  5. HTML——meta标签

    <meta> 元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词. <meta> 标签位于文档的头部,不包含任何内容.&l ...

  6. C# 非托管内存使用时的注意事项

    调用Marshal.AllocHGlobal必须调用 Marshal.FreeHGlobal(ptr)来手动释放内存,即使调用GC.Collect();方法也无法释放,导致内存泄露!!

  7. c里面的fflush函数

    NAME fflush - flush a stream SYNOPSIS #include <stdio.h> int fflush(FILE *stream); DESCRIPTION ...

  8. linux的提示信息--/etc/motd和/etc/issue

    /etc/motd 即 message of the day 每次用户登录时,这个文件的内容都会显示在用户的终端上.如果shell支持中文,还可以使用中文,这样看起来更加舒服. 成功登录后,自动输出. ...

  9. qq开放平台测试

    2015年3月10日 11:29:56 QQ API对一些链接的curl请求时, 有https, 所以需要安装openssl:  Linux上要安装openssl #yum -y install op ...

  10. 7.nodejs权威指南--加密与压缩

    1. 加密与压缩 1.1 加密 var crypto = require('crypto'); var text = "12345678"; var hasher = crypto ...