QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201170#7339. A Really Odd SequencekjhhjkiWA 923ms50400kbC++20757b2023-10-05 12:54:002023-10-05 12:54:02

Judging History

This is the latest submission verdict.

  • [2023-10-05 12:54:02]
  • Judged
  • Verdict: WA
  • Time: 923ms
  • Memory: 50400kb
  • [2023-10-05 12:54:00]
  • Submitted

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);
    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: 0ms
memory: 3516kb

input:

1
4
8 -7 9 1

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: -100
Wrong Answer
time: 923ms
memory: 50400kb

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
6
9
11
12
13
13
13
13
13
13
13
13
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
15
...

result:

wrong answer 2nd numbers differ - expected: '3', found: '6'