QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#223386#7339. A Really Odd Sequenceehab_rafatWA 214ms11260kbC++14831b2023-10-22 01:28:362023-10-22 01:28:37

Judging History

This is the latest submission verdict.

  • [2023-10-22 01:28:37]
  • Judged
  • Verdict: WA
  • Time: 214ms
  • Memory: 11260kb
  • [2023-10-22 01:28:36]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define LSB(i) ((i) & (-i))
#define ll long long
const int dx[]{-1,1,0,0,-1,-1,1,1};
const int dy[]{0,0,1,-1,-1,1,-1,1};
const int MOD = 1e9+7;
const int inf = 1e9+1; 


#define int ll

void solve(int testCase)  {
    int n; cin >> n;
    vector<int>v(n);
    for(int& x : v) cin >> x;
    int sum = -1e18, mx = -1e18, j = -1;
    for(int i = 0; i < n; ++i){
        if(v[i] > sum+v[i]){
            sum = v[i];
            j = i;
        } else sum += v[i];
        if((i-j+1)&1)mx = max(mx, sum);
    }
    cout << mx << '\n';
}   

int32_t main(){
    fastio();  
    int t = 1;
    cin >> t;
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    return 0;
}

詳細信息

Test #1:

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

input:

1
4
8 -7 9 1

output:

10

result:

ok 1 number(s): "10"

Test #2:

score: -100
Wrong Answer
time: 214ms
memory: 11260kb

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
3
3
3
1
3
1
1
2
4
1
1
2
6
1
1
4
2
1
1
4
1
2
2
3
1
4
0
1
1
3
1
1
2
2
3
0
5
1
1
2
1
1
2
3
2
1
2
1
3
1
2
3
2
3
2
2
1
5
0
3
2
2
2
2
1
0
2
2
3
2
1
2
0
2
1
1
2
2
1
2
1
1
3
0
2
1
1
2
1
2
2
3
2
1
2
1
1
3
3
1
1
2
1
1
2
1
2
2
1
1
1
3
3
2
1
3
2
3
2
1
3
1
1
2
4
3
5
2
2
4
1
1
2
1
1
1
2
5
3
3
0
2
2
2
1
1
2
1
2
...

result:

wrong answer 9th numbers differ - expected: '3', found: '2'