QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#629063 | #9266. Dynamic Traffic with MegaFon | ucup-team3474 | WA | 0ms | 3852kb | C++23 | 897b | 2024-10-11 02:29:44 | 2024-10-11 02:29:45 |
Judging History
answer
#include<bits/stdc++.h>
#define F(i, a, b) for(int i = a; i <= b; i ++)
#define Fd(i, a, b) for(int i = a; i >= b; i --)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define int long long
using namespace std;
const int mod = 998244353;
const int N = 5e5 + 10;
const int inf = 1e18;
typedef array<int, 3> a3;
typedef long long ll;
int n, m, a[N];
void sol() {
cin >> n;
F(i, 1, n) cin >> a[i];
vector<int> res;
F(i, 1, n) {
if(a[i] >= 0) res.push_back(a[i]);
else if(res.size() && res.back() >= 0) res.push_back(a[i]);
}
int ans = 0;
for(int i = 1; i < res.size(); i ++) {
ans += max(res[i], res[i - 1]);
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
F(i, 1, t) sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
4 5 -3 -2 1
output:
6
result:
ok answer is '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
4 -1 -1 -1 -1
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1 0
output:
0
result:
ok answer is '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1 -1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
10 -459 615 -847 354 -816 127 727 729 593 -676
output:
4228
result:
wrong answer expected '4843', found '4228'