-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
43 lines (37 loc) · 806 Bytes
/
Copy pathA.cpp
File metadata and controls
43 lines (37 loc) · 806 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int xxxx[]={-1,0,1,0,-1,1,1,-1};
int yyyy[]={0,1,0,-1,-1,1,-1,1};
int arr[100000];
int N, Q;
bool check(int m) {
int q = Q;
for (int i = m; i < N; i++) {
if (arr[i] > q) q--;
}
return q < 0;
}
void solve(){
cin >> N >> Q;
for (int i = 0; i < N; i++) cin >> arr[i];
int l = -1, r = N, m;
while (l + 1 < r) {
int m = (l + r) / 2;
if (check(m)) l = m;
else r = m;
}
for (int i = 0; i < r; i++) cout << (arr[i] <= Q);
for (int i = r; i < N; i++) cout << 1;
}
int main()
{
cin.tie(0)->sync_with_stdio(false);
int T=1;
cin >>T;
while (T--) {
solve();
cout << '\n';
}
return 0;
}