QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#177267 | #5080. Folding Stick | dj4zo6u_6 | WA | 0ms | 3580kb | C++14 | 714b | 2023-09-12 19:30:32 | 2023-09-12 19:30:33 |
Judging History
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'