QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709527#5080. Folding StickOOBMABTRAMS#WA 1ms5740kbC++17439b2024-11-04 15:12:472024-11-04 15:12:48

Judging History

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

  • [2024-11-04 15:12:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5740kb
  • [2024-11-04 15:12:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=500013;
int a[N],b[N];
int n,dp[N];
int main(){
    int k=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i],b[i]=b[i-1]+a[i];
    for(int i=1;i<=n;i++) {
        while(b[i]-b[k+1]>=dp[k+1]&&k+1<i)k++;
        dp[i]=b[i]-b[k];
    }
    int ans=2e9;
    for(int i=1;i<=n;i++)ans=min(ans,max(dp[i],b[n]-b[i]));
    cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5740kb

input:

4
3 2 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5632kb

input:

5
1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5612kb

input:

7
1 3 2 3 4 2 2

output:

6

result:

ok single line: '6'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5680kb

input:

9
5 6 3 4 8 8 2 2 5

output:

9

result:

ok single line: '9'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 5600kb

input:

10
5 6 3 4 8 6 2 1 8 5

output:

13

result:

wrong answer 1st lines differ - expected: '9', found: '13'