QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#252403 | #5080. Folding Stick | NYCU_gAwr_gurA# | WA | 0ms | 3708kb | C++17 | 771b | 2023-11-15 19:17:04 | 2023-11-15 19:17:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define cerr if(1);else cerr
#define endl '\n'
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
const int O=1e5;
int pr[O+1], dp[O+1];
signed main() {
fast;
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>pr[i], pr[i]+=pr[i-1];
int ans=2e9;
for(int i=1;i<=n;i++)
{
int l=0,r=i;
while(l<r)
{
int m=l+(r-l)/2;
if(dp[m]<=pr[i]-pr[m])
l=m+1;
else
r=m;
}
dp[i]=pr[i]-pr[l-1];
ans=min(ans, max(dp[i], pr[n]-pr[i]));
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
input:
4 3 2 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
7 1 3 2 3 4 2 2
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
9 5 6 3 4 8 8 2 2 5
output:
9
result:
ok single line: '9'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
10 5 6 3 4 8 6 2 1 8 5
output:
9
result:
ok single line: '9'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
10 5 8 1 2 6 8 4 3 6 5
output:
14
result:
ok single line: '14'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3 4 2 1
output:
4
result:
ok single line: '4'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
14 7 2 2 2 2 3 4 1 3 5 4 3 1 6
output:
12
result:
wrong answer 1st lines differ - expected: '8', found: '12'