Bear and Displayed Friends

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer ti. The bigger this value is, the better the friendship is. No two friends have the same value ti.

Spring is starting and the Winter sleep is over for bears. Limak has just woken up and logged in. All his friends still sleep and thus none of them is online. Some (maybe all) of them will appear online in the next hours, one at a time.

The system displays friends who are online. On the screen there is space to display at most k friends. If there are more than k friends online then the system displays only k best of them — those with biggest ti.

Your task is to handle queries of two types:

“1 id” — Friend id becomes online. It’s guaranteed that he wasn’t online before.

“2 id” — Check whether friend id is displayed by the system. Print “YES” or “NO” in a separate line.

Are you able to help Limak and answer all queries of the second type?

Input

The first line contains three integers n, k and q (1 ≤ n, q ≤ 150 000, 1 ≤ k ≤ min(6, n)) — the number of friends, the maximum number of displayed online friends and the number of queries, respectively.

The second line contains n integers t1, t2, …, tn (1 ≤ ti ≤ 109) where ti describes how good is Limak’s relation with the i-th friend.

The i-th of the following q lines contains two integers typei and idi (1 ≤ typei ≤ 2, 1 ≤ idi ≤ n) — the i-th query. If typei = 1 then a friend idi becomes online. If typei = 2 then you should check whether a friend idi is displayed.

It’s guaranteed that no two queries of the first type will have the same idi becuase one friend can’t become online twice. Also, it’s guaranteed that at least one query will be of the second type (typei = 2) so the output won’t be empty.

Output

For each query of the second type print one line with the answer — “YES” (without quotes) if the given friend is displayed and “NO” (without quotes) otherwise.

Examples

input

4 2 8

300 950 500 200

1 3

2 4

2 3

1 1

1 2

2 1

2 2

2 3

output

NO

YES

NO

YES

YES

input

6 3 9

50 20 51 17 99 24

1 3

1 4

1 5

1 2

2 4

2 2

1 1

2 4

2 3

output

NO

YES

NO

YES

其实没必要用优先队列的

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <queue> using namespace std;
#define MAX 150000
int n,k,q1;
struct Node
{
int pos;
int value;
friend bool operator <(Node a,Node b)
{
return a.value>b.value;
}
}a[MAX+5];
int tag[MAX+5];
int main()
{
int x,y;
scanf("%d%d%d",&n,&k,&q1);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i].value);
a[i].pos=i;
}
priority_queue<Node> q;
memset(tag,0,sizeof(tag));
for(int i=1;i<=q1;i++)
{
scanf("%d%d",&x,&y);
if(x==1)
{
if(q.size()<k)
{
q.push(a[y]);
tag[y]=1;
}
else
{
Node term=q.top();
if(a[y].value>term.value)
{
q.pop();
tag[term.pos]=0;
q.push(a[y]);
tag[y]=1;
}
}
}
else if(x==2)
{
if(tag[y])
printf("YES\n");
else
printf("NO\n");
} }
return 0;
}

CodeForces 639 A的更多相关文章

  1. Codeforces Round #639 (Div. 2)

    Codeforces Round #639 (Div. 2) (这场官方搞事,唉,just solve for fun...) A找规律 给定n*m个拼图块,每个拼图块三凸一凹,问能不能拼成 n * ...

  2. [Codeforces 639B] Bear and Forgotten Tree 3

    [题目链接] https://codeforces.com/problemset/problem/639/B [算法] 当d > n - 1或h > n - 1时 , 无解 当2h < ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. Linux下使用DD命令测试磁盘读写速度

    dd是Linux/UNIX 下的一个非常有用的命令,作用是用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换,所以可以用来测试硬盘的读写能力~ 几种常见的DD命令,先看一下区别~ dd bs=6 ...

  2. Lambda编写斐波那契数列

    还需要考虑溢出等问题,闲来无事写了写 Func<float, float, float> a = (arg1, arg2) => 0f;//init ; a = (lastNumbe ...

  3. UITableView__cell 距tableview顶端有间距

    UITableView__cell 距tableview顶端有间距     如何去掉这个间距呢?解决方法如下: //top 为cell距顶端的间距 (一般为负值) self.formTable.con ...

  4. jsp学习之scriptlet的使用方法

    scriptlet的使用 jsp页面中分三种scriptlet: 第一种:<%  %>  可以在里面写java的代码.定义java变量以及书写java语句. 第二种:<%! %> ...

  5. 如何重设 MySQL 的 root 密码

    MySQL下创建新用户.新数据库.设定访问权限控制都需要用到root密码.万一把root密码忘了,该怎么办? 幸运地是,重设密码很容易. 安全模式重置法 基本的思路是,以安全模式启动mysql,这样不 ...

  6. Python 将json字符串 进行列表化可循环

    import json data = [{1:':'d'}] json.loads(datas))

  7. C#如何调用其他.config配置文件,就是2个乃至3个以上的config文件

    XmlDocument xDoc = new XmlDocument(); try { xDoc.Load(配置文件路径); XmlNode xNode; XmlElement xElem; xNod ...

  8. Can't zip RDDs with unequal numbers of partitions

    java.lang.IllegalArgumentException: Can't zip RDDs with unequal numbers of partitions //如果两个RDD分区数不同 ...

  9. Centsos7修改密码

    CentOS 7.0 进入单用户模式修改Root密码 时间:2017-05-02 01:10来源:blog.csdn.net  作者:海哥_大大的Java 举报   点击:506次 一.启动时,随便按 ...

  10. Redis list 之增删改查

    一.增加 1.lpush [lpush key valus...]  类似于压栈操作,将元素放入头部 127.0.0.1:6379> lpush plist ch0 ch1 ch2 (integ ...