QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#177267#5080. Folding Stickdj4zo6u_6WA 0ms3580kbC++14714b2023-09-12 19:30:322023-09-12 19:30:33

Judging History

你现在查看的是最新测评结果

  • [2023-09-12 19:30:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2023-09-12 19:30:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long

void solve();
signed main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    solve();
}

void solve(){
    int n;
    cin>>n;
    vector<ll>a(n+5,0),dp(n+5,2e9),s(n+5,0);
    for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+a[i];
    dp[0]=0;
    for(int i=1;i<=n;i++){
        int l=0;
        for(int r=i+1,m;l+1<r;){
            m=(l+r)/2;
            if(dp[m]+s[m]<=s[i])l=m;
            else r=m;
        }
        dp[i]=s[i]-s[l];
    }
    ll mn=dp[n];
    for(int j=n;j>=0;j--){
        mn=min<ll>(mn,max<ll>(s[n]-s[j],dp[j]));
    }
    for(int i=0;i<=n;i++)cout<<dp[i]<<",\n"[i==n];
    cout<<mn<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

input:

4
3 2 2 3

output:

0,3,5,4,5
4

result:

wrong answer 1st lines differ - expected: '4', found: '0,3,5,4,5'