QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#268185 | #5080. Folding Stick | STnofarjo# | WA | 0ms | 3704kb | C++20 | 551b | 2023-11-28 12:44:05 | 2023-11-28 12:44:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 131072;
long long n, idx = 0, sum[maxn], ans[maxn];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i=1; i<=n; i++){
cin >> sum[i]; sum[i] += sum[i-1];
while(idx < i-1 && ans[idx+1] <= sum[i] - sum[idx+1]){
idx++;
}
ans[i] = sum[i] - sum[idx];
//cout << i << ": " << idx << ' ' << ans[i] << endl;
}
for(int i=0; i<n; i++){
ans[n] = min(max(ans[i], sum[n]-sum[i]), ans[n]);
}
cout << ans[n] << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
4 3 2 2 3
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
5 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
7 1 3 2 3 4 2 2
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
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: 0ms
memory: 3704kb
input:
10 5 6 3 4 8 6 2 1 8 5
output:
13
result:
wrong answer 1st lines differ - expected: '9', found: '13'