https://codeforces.com/contest/1978
C:
D:
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mkp make_pair
#define lowbit(x) ((x&(-x)))
#define int long long
const int maxn=2e5+10;
const int mod=998244353;
int n,a[maxn],pre[maxn],mx[maxn],f[maxn];
void solve(){
int c;cin>>n>>c;
for(int i=1;i<=n;i++){
cin>>a[i];
if(i==1)a[i]+=c;
pre[i]=pre[i-1]+a[i];
}
mx[n+1]=0;
mx[n]=a[n];
for(int i=n-1;i>=1;i--){
mx[i]=max(a[i],mx[i+1]);
}
bool x=0;
for(int i=1;i<=n;i++){
if(a[i]==mx[1]&&(!x))f[i]=0,x=1;
else{
if(mx[i+1]>pre[i]){
f[i]=i;
}
else f[i]=i-1;
}
cout<<f[i]<<' ';
}
cout<<"\n";
}
signed main(){
ios::sync_with_stdio(false);
// 解除cin和cout的默认绑定,来降低IO的负担使效率提升
cin.tie(NULL); cout.tie(NULL);
int tt;cin>>tt;while(tt--){
solve();
}
}
标签:pre,const,int,953,Cf,maxn,Div,mx,define
From: https://www.cnblogs.com/lyrrr/p/18409256