A15191 | Doremy's IQ
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
If Doremy chooses to test contest $i$ on day $i$ , the following happens:
- if $a_i>q$ , Doremy will feel she is not wise enough, so $q$ decreases by $1$ ;
- otherwise, nothing changes.
If she chooses not to test a contest, nothing changes.Doremy wants to test as many contests as possible. Please give Doremy a solution.
If Doremy chooses to test contest $i$ on day $i$ , the following happens:
- if $a_i>q$ , Doremy will feel she is not wise enough, so $q$ decreases by $1$ ;
- otherwise, nothing changes.
If she chooses not to test a contest, nothing changes.Doremy wants to test as many contests as possible. Please give Doremy a solution.
输入格式
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.
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.
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.
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
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.
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.
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
输出格式
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.
If there are multiple solutions, you may output any.
If there are multiple solutions, you may output any.
输入输出样例
输入 #1
5 1 1 1 2 1 1 2 3 1 1 2 1 4 2 1 4 3 1 5 2 5 1 2 4 3
输出 #1
1 11 110 1110 01111
In the first test case, Doremy tests the only contest. Her IQ doesn't decrease.
In the second test case, Doremy tests both contests. Her IQ decreases by $1$ after testing contest $2$ .
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$ .
In the second test case, Doremy tests both contests. Her IQ decreases by $1$ after testing contest $2$ .
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted