有两种情况:
第一种情况: 智商q>=n, 这种情况直接全输出1
第二种情况: 智商q<n , 对于大于智商的比赛需要考虑要不要参加, 从后往前贪心就是最优解, 最后的智商是0, 每当有大于智商的比赛就智商+1, 注意增加智商的次数不超过q, 超过q且智商小于比赛的时候就不能参加比赛了, 最后注意倒序输出, 否则顺序不对也会wa
ac代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#include <stack>
#include <deque>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, b) for (ll i = (a); i <= (b); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepr(i, a, b) for (ll i = (b); i > (a); i--)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)
ll cnt,n,m,t,ans,ant;
const int N=1e5+10;
ll arr[N];
string str;
inline ll read()
{
char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}//是符号
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}//是数字
return x*s;
}
void solve()
{
ll q;
str.clear();
ans=0;
scanf("%lld%lld",&n,&q);
rep(i,1,n)
scanf("%lld",&arr[i]);
if(q>=n)
{
rep(i,1,n) cout<<'1';
puts("");
return;
}
cnt=0;//最后的智商
rrep(i,1,n)
{
if(cnt>=arr[i])
{
str.push_back('1');
}else if(cnt<arr[i]&&q)
{
q--;
cnt++;
str.push_back('1');
}else
{
str.push_back('0');
}
}
reverse(str.begin(),str.end());
cout<<str<<endl;
return;
}
int main()
{
cin>>t;
while(t--)
solve();
return 0;
}