标签:mes return out color 长度 red cout turn codeforce
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=500005; const ll INF=(1LL<<60)-1; int a[N]; ll sum[N]; int main() { int n; cin>>n; for(int i=1; i<=(n+1)/2; i++) cin>>a[i]; int x; cin>>x; for(int i=(n+1)/2+1; i<=n; i++) a[i]=x; for(int i=n; i>=1; i--) sum[i]=sum[i+1]+a[i];//后缀和 ll now=INF; //当长度为n的时候 区间左端点为1~1 //长度为n-1 1~2 // n-2 1~3 //当长度变小的时候 就是 减去了一个x for(int k=n; k>n/2; k--) { now=min(now-x,sum[n-k+1]); if(now>0) { cout<<k<<endl; return 0; } } cout<<"-1"<<endl; return 0; }
Codeforces Round #645 (Div. 2) E - Are You Fired? 尺取?
标签:mes return out color 长度 red cout turn codeforce
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12985099.html