-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtoi06_schedule.cpp
59 lines (51 loc) · 916 Bytes
/
toi06_schedule.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1e9 + 7
int n,k,m;
vector<pair<int,int> > a(500001);
vector<int> s(500001);
bool ok[500001];
void update(int idx)
{
while(idx<=500000)
{
s[idx]++;
idx+=(idx & -idx);
}
}
int read(int idx)
{
int val = 0;
while(idx > 0)
{
val+=s[idx];
idx-=(idx & -idx);
}
return val;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k >> m;
for(int i = 0;i < n;i++)
{
int x,y;
cin >> x >> y;
a[x] = {y,i};
}
for(int i = 1;i <= 500000;i++)
{
if(a[i].first==0) continue;
if(read(500000)-read(i-1)>=k) continue;
update(a[i].first);
ok[a[i].second] = true;
}
while(m--)
{
int x;
cin >> x;
if(ok[x-1]) cout << "Y ";
else cout << "N ";
}
}