QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#578491#9266. Dynamic Traffic with MegaFonAWR#WA 0ms3820kbC++20526b2024-09-20 19:31:552024-09-20 19:31:55

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 19:31:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-09-20 19:31:55]
  • 提交

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'