Codeforces 639A Bear and Displayed Friends (优先队列)
来源:互联网 发布:描绘网络的 电影 编辑:程序博客网 时间:2024/05/19 12:25
题目链接:点击打开链接
#include<stdio.h>
#include<queue>
using namespace std;
struct node{
int id,val;
}num[150010];
int visit[150010];
bool operator<(const node &a,const node &b)
{
return a.val>b.val;
}
int main()
{
int n,k,m,i,op,x;
node now;
while(~scanf("%d%d%d",&n,&k,&m))
{
for(i=1;i<=n;i++)
{
scanf("%d",&num[i].val);
num[i].id=i;
visit[i]=0;
}
priority_queue<node>q;
while(m--)
{
scanf("%d%d",&op,&x);
if(op==1)
{
q.push(num[x]);
visit[x]=1;
if(q.size()>k)
{
visit[q.top().id]=0;
q.pop();
}
}
else
if(visit[x]==1)
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}
0 0
- Codeforces 639A Bear and Displayed Friends (优先队列)
- CodeForces 639 A.Bear and Displayed Friends(水~)
- Codeforces 639A Bear and Displayed Friends 【STL】
- A. Bear and Displayed Friends
- CodeForces 658B Bear and Displayed Friends(树状数组)
- codeforces 658B-Bear and Displayed Friends
- VK Cup 2016 - Round 1 (Div. 2 Edition) B B. Bear and Displayed Friends 优先队列
- Codeforces 658B Bear and Displayed Friends【set】
- CodeForces 658B Bear and Displayed Friends(好友在线查询)
- Codeforces Round #318 574A Bear and Elections(优先队列)
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) A. Bear and Elections(优先队列)
- Codeforces #318 (Div. 2 A. Bear and Elections (模拟/优先队列
- VK Cup 2016 - Round 1 (Div. 2 Edition)-B - Bear and Displayed Friends-STL(维护前k大)
- 【VK Cup 2016 - Round 1 (Div 2 Edition)B】【水题】Bear and Displayed Friends 即时维护最大6个数
- Codeforces 385A Bear and Raspberry(水题)
- CodeForces - 658A Bear and Reverse Radewoosh (模拟)水
- Codeforces--658A--Bear and Reverse Radewoosh(模拟)
- 【Codeforces Round】351A - Bear and Game(水)
- Struts2
- MySQL(3):CRUD语句(1)——增、删、改
- Python3 基础:高级特性-列表生成式和生成器
- python学习笔记(二) BeautifulSoup
- mvc-路由类
- Codeforces 639A Bear and Displayed Friends (优先队列)
- 633(二叉树的遍历,二叉树重建)
- reactor模式
- ROS_tf_2016_1_25
- 用开源项目ExpandableTextView打造可以下拉扩展的TextView
- Hibernate与 MyBatis的比较
- System.out.println与System.err.println的区别
- Action
- mybatis与hibernate区别