QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578491 | #9266. Dynamic Traffic with MegaFon | AWR# | WA | 0ms | 3820kb | C++20 | 526b | 2024-09-20 19:31:55 | 2024-09-20 19:31:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define vv vector
#define eb emplace_back
#define Fr(i, l, r) for (ll i = l; i <= r; ++i)
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n; cin >> n;
vv<ll> a(n + 2), b;
Fr (i, 1, n) cin >> a[i];
Fr (i, 1, n) {
if (a[i] >= 0) b.eb(a[i]);
else if (!b.empty() && b.back() >= 0) b.eb(a[i]);
}
ll K = b.size(), ans = 0;
Fr (i, 0, K - 2) ans += max(b[i], b[i + 1]);
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
4 5 -3 -2 1
output:
6
result:
ok answer is '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
4 -1 -1 -1 -1
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
1 0
output:
0
result:
ok answer is '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
1 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
1 -1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3536kb
input:
10 -459 615 -847 354 -816 127 727 729 593 -676
output:
4228
result:
wrong answer expected '4843', found '4228'