Submission #1019339

# Submission time Handle Problem Language Result Execution time Memory
1019339 2024-07-10T17:48:31 Z Nicolaikrob Feast (NOI19_feast) C++17
59 / 100
135 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    ll A[n+1], DP[n+1][k+1], PS[n+1], B[k+1];
    A[0] = PS[0] = 0;
    for(int i = 1; i <= n; i++) cin >> A[i], PS[i] = PS[i-1]+A[i];
    for(int i = 0; i < k+1; i++) B[i] = PS[n];
    for(int i = 0; i < n+1; i++) DP[i][0] = 0;
    for(int i = 0; i < k+1; i++) DP[0][i] = 0;
    for(int i = 1; i <= n; i++) {
        B[0] = max(B[0], PS[n]-PS[i]);
        for(int j = 1; j <= k; j++) {
            DP[i][j] = max(DP[i-1][j], B[j-1]-(PS[n]-PS[i]));
            B[j] = max(B[j], DP[i][j]+(PS[n]-PS[i]));
        }
    }
    cout << DP[n][k];
}
# Verdict Execution time Memory Grader output
1 Runtime error 124 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 10576 KB Output is correct
2 Correct 40 ms 10836 KB Output is correct
3 Correct 40 ms 10580 KB Output is correct
4 Runtime error 135 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 84 ms 12624 KB Output is correct
2 Correct 86 ms 12368 KB Output is correct
3 Correct 115 ms 12628 KB Output is correct
4 Correct 84 ms 12392 KB Output is correct
5 Correct 83 ms 12460 KB Output is correct
6 Correct 88 ms 12624 KB Output is correct
7 Correct 82 ms 12696 KB Output is correct
8 Correct 93 ms 12628 KB Output is correct
9 Correct 103 ms 12624 KB Output is correct
10 Correct 93 ms 12548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 436 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 436 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 436 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 3420 KB Output is correct
22 Correct 20 ms 26044 KB Output is correct
23 Correct 6 ms 6236 KB Output is correct
24 Correct 3 ms 3664 KB Output is correct
25 Correct 5 ms 4972 KB Output is correct
26 Correct 3 ms 3160 KB Output is correct
27 Correct 4 ms 4700 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 1 ms 860 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 124 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -