QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201173 | #7339. A Really Odd Sequence | kjhhjki | WA | 1116ms | 50320kb | C++20 | 781b | 2023-10-05 12:55:32 | 2023-10-05 12:55:32 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 100005
#define For(I,A,B) for(int I = (A), endi = (B); I <= endi; ++I)
#define foR(I,A,B) for(int I = (A), endi = (B); I >= endi; --I)
#define ForE(I,A) for(int I = head[A]; I; I = e[I].nxt)
using namespace std;
typedef long long _ll;
typedef unsigned int ui;
int T,n,x;
_ll sum,ans;
void solve()
{
cin >> n; set<_ll> s[2]; s[0].insert(0); ans = -0x7ffffffffffll;
For(i,1,n)
{
cin >> x;
sum += x; s[i&1].insert(sum);
int p = !(i&1);
if(s[p].empty()) continue;
ans = max(ans,sum - *s[p].begin());
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> T;
while(T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3428kb
input:
1 4 8 -7 9 1
output:
10
result:
ok 1 number(s): "10"
Test #2:
score: -100
Wrong Answer
time: 1116ms
memory: 50320kb
input:
59056 10 0 1 1 0 1 0 1 1 1 0 10 -1 -1 -1 1 0 0 1 0 0 1 10 1 0 0 1 1 1 -1 -1 0 1 10 -1 1 -1 1 0 1 1 0 -1 1 10 1 0 0 1 -1 0 -1 -1 -1 1 10 1 1 1 0 0 -1 -1 1 0 0 10 -1 1 0 0 1 -1 -1 0 -1 -1 10 1 -1 0 0 0 -1 -1 -1 -1 -1 10 0 0 0 1 1 0 0 1 -1 1 10 0 -1 0 0 1 0 1 1 1 0 10 0 0 0 0 1 -1 1 -1 -1 -1 10 -1 0 1 ...
output:
6 5 9 11 12 13 13 10 6 10 11 9 10 15 15 12 13 12 10 8 9 7 8 7 5 3 5 5 4 2 3 1 1 2 2 3 0 4 1 1 2 1 1 1 3 2 1 2 1 3 1 1 3 2 3 1 3 2 5 1 3 1 2 2 2 1 1 2 2 2 2 1 3 1 2 1 1 2 1 1 2 1 1 3 1 3 1 1 2 1 2 2 3 2 1 2 1 1 1 3 1 1 1 1 1 3 1 2 2 1 1 1 3 3 1 1 3 2 2 2 2 4 2 1 2 4 3 5 2 2 3 1 0 2 1 1 2 2 4 3 3 0 2 ...
result:
wrong answer 2nd numbers differ - expected: '3', found: '5'