QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#223385 | #7339. A Really Odd Sequence | ehab_rafat | WA | 225ms | 11236kb | C++14 | 823b | 2023-10-22 01:27:41 | 2023-10-22 01:27:41 |
Judging History
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;
}
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: 3464kb
input:
1 4 8 -7 9 1
output:
10
result:
ok 1 number(s): "10"
Test #2:
score: -100
Wrong Answer
time: 225ms
memory: 11236kb
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:
633313112411261142114122314011311223051121123212131232322150322221022321202112212113021121223212113311211212211133213232131124352241121112533022211212212313212121113213121031122327231223120121121311303131142151111412101311212116311231112111122311322401114221122223153221221210111214511317212311221230...
result:
wrong output format Expected integer, but "633313112411261142114122314011...1121324251221211110232421211221" found