-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBear_And_Displayed_Friends.cpp
More file actions
46 lines (45 loc) · 1.03 KB
/
Bear_And_Displayed_Friends.cpp
File metadata and controls
46 lines (45 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,q;
cin>>n>>k>>q;
int t[n];
for(int i=0;i<n;i++)
cin>>t[i];
priority_queue< int, vector<int> , greater<int> > minheap;
int x,y;
for(int i=0;i<q;i++)
{
cin>>x>>y;
if(x==1)
{
minheap.push(t[y-1]);
if(minheap.size()>k)
minheap.pop();
}
else
{
vector<int> vec;
bool f=false;
while(minheap.empty()==false)
{
int rx=minheap.top();
if(rx==t[y-1])
{
f=true;
break;
}
vec.push_back(rx);
minheap.pop();
}
for(int i=0;i<vec.size();i++)
minheap.push(vec[i]);
if(f==true)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
return 0;
}