Submission #833146

# Submission time Handle Problem Language Result Execution time Memory
833146 2023-08-22T02:27:48 Z veehj Feast (NOI19_feast) C++17
12 / 100
128 ms 4788 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
int n, k; vector<ll> a={0};

void f(){
    ll ans = 0;
    ll nw = 0;
    for(auto& u : a){
        nw = max((ll)0, nw + u);
        ans = max(ans, nw);
    }
    cout << ans << endl;
    return;
}

int main(){
    cin >> n >> k;
    vector<ll> v;
    for(int i=0; i<n; i++){
        ll x; cin >> x;
        if(x<=0){
            if(a[a.size()-1]<=0) v[v.size()-1]-=x;
            else v.pb(-1*x);
        }
        a.pb(x);
    }
    if(k==1){
        f();
        return 0;
    }
    ll cnt=0;
    for(auto& u : a) if(u>0) cnt+=u;
    cout << cnt << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 86 ms 4780 KB Output is correct
2 Correct 87 ms 4700 KB Output is correct
3 Correct 91 ms 4772 KB Output is correct
4 Correct 87 ms 4688 KB Output is correct
5 Correct 82 ms 4712 KB Output is correct
6 Correct 82 ms 4776 KB Output is correct
7 Correct 81 ms 4780 KB Output is correct
8 Correct 87 ms 4708 KB Output is correct
9 Correct 101 ms 4740 KB Output is correct
10 Correct 84 ms 4784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 4712 KB Output is correct
2 Correct 46 ms 4684 KB Output is correct
3 Correct 45 ms 4780 KB Output is correct
4 Correct 45 ms 4780 KB Output is correct
5 Correct 128 ms 4692 KB Output is correct
6 Correct 45 ms 4696 KB Output is correct
7 Correct 44 ms 4664 KB Output is correct
8 Correct 82 ms 4692 KB Output is correct
9 Correct 82 ms 4704 KB Output is correct
10 Correct 47 ms 4788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 304 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 304 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 304 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 86 ms 4780 KB Output is correct
2 Correct 87 ms 4700 KB Output is correct
3 Correct 91 ms 4772 KB Output is correct
4 Correct 87 ms 4688 KB Output is correct
5 Correct 82 ms 4712 KB Output is correct
6 Correct 82 ms 4776 KB Output is correct
7 Correct 81 ms 4780 KB Output is correct
8 Correct 87 ms 4708 KB Output is correct
9 Correct 101 ms 4740 KB Output is correct
10 Correct 84 ms 4784 KB Output is correct
11 Correct 54 ms 4712 KB Output is correct
12 Correct 46 ms 4684 KB Output is correct
13 Correct 45 ms 4780 KB Output is correct
14 Correct 45 ms 4780 KB Output is correct
15 Correct 128 ms 4692 KB Output is correct
16 Correct 45 ms 4696 KB Output is correct
17 Correct 44 ms 4664 KB Output is correct
18 Correct 82 ms 4692 KB Output is correct
19 Correct 82 ms 4704 KB Output is correct
20 Correct 47 ms 4788 KB Output is correct
21 Runtime error 1 ms 340 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -