QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#127900#5080. Folding Stickbatrr#WA 1ms3612kbC++171.3kb2023-07-20 11:15:382023-07-20 11:15:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-20 11:15:39]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3612kb
  • [2023-07-20 11:15:38]
  • 提交

answer

#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 300500, inf = 1e9, mod = 998244353;
const ll INF = 1e18;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mult(int a, int b) {
    return 1ll * a * b % mod;
}

int bp(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return bp(x, mod - 2);
}

int n, a[N], ans;

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int x = 0, y = 0;
    for(int i = 0; i < n; i++){
        y += a[i];
        if(x <= y){
            x = y;
            y = 0;
            ans = x;
        }
    }
    cout << ans << endl;
}

int main() {
//#ifdef DEBUG
//    freopen("input.txt", "r", stdin);
//#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
//        cout << "Case #" << i << endl;
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3516kb

input:

4
3 2 2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

5
1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3400kb

input:

7
1 3 2 3 4 2 2

output:

6

result:

ok single line: '6'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3392kb

input:

9
5 6 3 4 8 8 2 2 5

output:

9

result:

ok single line: '9'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3396kb

input:

10
5 6 3 4 8 6 2 1 8 5

output:

9

result:

ok single line: '9'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

10
5 8 1 2 6 8 4 3 6 5

output:

14

result:

ok single line: '14'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

3
4 2 1

output:

4

result:

ok single line: '4'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

14
7 2 2 2 2 3 4 1 3 5 4 3 1 6

output:

8

result:

ok single line: '8'

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3576kb

input:

35
46 93 64 27 72 55 77 11 17 17 79 83 74 26 32 101 54 112 92 111 77 60 51 19 105 11 68 7 100 49 88 54 106 80 57

output:

377

result:

wrong answer 1st lines differ - expected: '366', found: '377'