Codeforces Round #645 (Div. 2) E - Are You Fired? 尺取?

Posted qingyuyyyyy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #645 (Div. 2) E - Are You Fired? 尺取?相关的知识,希望对你有一定的参考价值。

#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? 尺取?的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #645 (Div. 2)

Codeforces Round #645 (Div. 2)

Codeforces Round #645 (Div. 2) 题解 (ABCD) (E一定补!)

Codeforces Round #645 (Div. 2) 题解 (ABCD) (E一定补!)

Codeforces Round #645 (Div. 2) C - Celex Update 思维

Codeforces Round #645 (Div. 2) C - Celex Update 思维