T4这题折腾我1h了,还没好
代码如下:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,l,r;
struct node{
int play;
int score;
int b=0;
};
node a[100005];
bool cmp1(node x,node y){
if(x.score!=y.score) return x.score>y.score;
return x.play<y.play;
}
bool cmp2(node x,node y){
return x.play<y.play;
}
bool check(int x){
int t=a[1].score;
for(int i=2;i<=n;i++) t=(t+a[i].score)/2;
if(t<=a[x].score) return 1;
return 0;
}
signed main(){
freopen("master.in","r",stdin);
freopen("master.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].score;
a[i].play=i;
}
sort(a+1,a+n+1,cmp1);
l=1,r=n;
while(l<r){
int mid=(l+r)/2;
if(check(mid)) l=mid+1;
else r=mid;
}
for(int i=1;i<l;i++) a[i].b=1;
sort(a+1,a+n+1,cmp2);
for(int i=1;i<=n;i++) cout<<a[i].b;
return 0;
}
WA,70pts
错误样例:输入:2 1 1
应输出:11
我输出:10