1707A.md (2145B)
1 Source: https://codeforces.com/problemset/problem/1707/A 2 3 A. Doremy's IQ 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Doremy is asked to test $n$ contests. Contest $i$ can only be tested on day $i$. The difficulty of contest $i$ is $a_i$. Initially, Doremy's IQ is $q$. On day $i$ Doremy will choose whether to test contest $i$ or not. She can only test a contest if her current IQ is strictly greater than $0$. 22 23 If Doremy chooses to test contest $i$ on day $i$, the following happens: 24 25 * if $a_i \gt q$, Doremy will feel she is not wise enough, so $q$ decreases by $1$; 26 * otherwise, nothing changes. 27 28 If she chooses not to test a contest, nothing changes. 29 30 Doremy wants to test as many contests as possible. Please give Doremy a solution. 31 32 Input 33 34 The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 10^4$) — the number of test cases. The description of the test cases follows. 35 36 The first line contains two integers $n$ and $q$ ($1 \le n \le 10^5$, $1 \le q \le 10^9$) — the number of contests and Doremy's IQ in the beginning. 37 38 The second line contains $n$ integers $a_1,a_2,\cdots,a_n$ ($1 \le a_i \le 10^9$) — the difficulty of each contest. 39 40 It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$. 41 42 Output 43 44 For each test case, you need to output a binary string $s$, where $s_i=1$ if Doremy should choose to test contest $i$, and $s_i=0$ otherwise. The number of ones in the string should be maximum possible, and she should never test a contest when her IQ is zero or less. 45 46 If there are multiple solutions, you may output any. 47 48 Example 49 50 Input 51 52 ``` 53 5 54 55 1 1 56 57 1 58 59 2 1 60 61 1 2 62 63 3 1 64 65 1 2 1 66 67 4 2 68 69 1 4 3 1 70 71 5 2 72 73 5 1 2 4 3 74 ``` 75 76 Output 77 78 ``` 79 1 80 11 81 110 82 1110 83 01111 84 ``` 85 86 Note 87 88 In the first test case, Doremy tests the only contest. Her IQ doesn't decrease. 89 90 In the second test case, Doremy tests both contests. Her IQ decreases by $1$ after testing contest $2$. 91 92 In the third test case, Doremy tests contest $1$ and $2$. Her IQ decreases to $0$ after testing contest $2$, so she can't test contest $3$.