Codeforces Round #808 (Div. 2)C - Doremy‘s IQ

C. Doremy’s IQ

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

Doremy is asked to test n contests. Contest i can only be tested on day i. The difficulty of contest i is ai. 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 ai>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.

Input
The input consists of multiple test cases. The first line contains a single integer t (1≤t≤104) — the number of test cases. The description of the test cases follows.

The first line contains two integers n and q (1≤n≤105, 1≤q≤109) — the number of contests and Doremy’s IQ in the beginning.

The second line contains n integers a1,a2,⋯,an (1≤ai≤109) — the difficulty of each contest.

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output
For each test case, you need to output a binary string s, where si=1 if Doremy should choose to test contest i, and si=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.

Example
inputCopy
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
outputCopy
1
11
110
1110
01111
Note
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.

原题链接:C. Doremy’s IQ

思路:这题顺着跑比较难想,因为IQ是递减的(越写题越傻)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值