C. Doremy‘s IQ

题目:

Doremy is asked to test nn contests. Contest ii can only be tested on day ii. The difficulty of contest ii is aiai. Initially, Doremy's IQ is qq. On day ii Doremy will choose whether to test contest ii or not. She can only test a contest if her current IQ is strictly greater than 00.

If Doremy chooses to test contest ii on day ii, the following happens:

  • if ai>qai>q, Doremy will feel she is not wise enough, so qq decreases by 11;
  • 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 tt (1≤t≤1041≤t≤104) — the number of test cases. The description of the test cases follows.

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

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

It is guaranteed that the sum of nn over all test cases does not exceed 105105.

Output

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

input

Copy

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

output

Copy

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 11 after testing contest 22.

In the third test case, Doremy tests contest 11 and 22. Her IQ decreases to 00 after testing contest 22, so she can't test contest 33.

题意:

有n道题目,这个人的智商只有x,如果这个人当前的智商大于等于题目难度,则可以ak这道题,反之,则需要智商减一且此时的智商是严格大于一才能ak这道题,二这个人想ak更多的题,请问他能ak哪些题?

题意:

我们此时需要反向思考,并作出预处理:

例如:

5 2

5 1 2 4 3

如果我们要做到最后一题,此时的智商至少应该为1,倒数第二道这里我们智商至少为2(因为可以相减),倒数第三道的时候我们的智商至少为2就行,同理倒数第四也是2,倒数第五也就是我们的第一道题此时的智商为3.

而这个样例显然01111这是我们的最佳答案,而不是11100。

然后我们再正向跑一遍,如果我们的智商大于等于题目难度,那么我们就可以ak,如果小于我们就要看这道题我们所需要的智商和当前的智商的大小关系,不能顾此失彼,只想着把当前的题ak了,而不顾后面,如果当前的智商大于等于我们所需要的最低智商我们就ak,所以我们这样的预处理,就不会顾此失彼了

#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long

using namespace std;

const int N = 2e5 + 10;

int n, x;
int arr[N], brr[N];

void solve()
{
     cin >> n >> x;

     for(int i = 1; i <= n; i ++) cin >> arr[i];

     for(int i = 1; i <= n+3; i ++) brr[i] = 0;
     for(int i = n; i >= 1; i --)
     {
          brr[i] = brr[i+1];
          if(brr[i] < arr[i]) brr[i]++;//预处理我们每道题当前所需要的最低智商
     }

     for(int i = 1; i <= n; i ++)
     {
          if(x >= arr[i]) cout << 1;
          else
          {
               if(x >= brr[i])
               {
                    x--;
                    cout << 1;
               }
               else
                    cout << 0;
          }
     }
     cout << '\n';
}

signed main()
{
     IOS;
     int T;
     cin >> T;
     while(T--)
          solve();
     return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值