QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#629063#9266. Dynamic Traffic with MegaFonucup-team3474WA 0ms3852kbC++23897b2024-10-11 02:29:442024-10-11 02:29:45

Judging History

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

  • [2024-10-11 02:29:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-10-11 02:29:44]
  • 提交

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'