Submission #969925

# Submission time Handle Problem Language Result Execution time Memory
969925 2024-04-25T21:03:06 Z blackslex Feast (NOI19_feast) C++17
21 / 100
1000 ms 262144 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int n, k;

int main() {
    scanf("%d %d", &n, &k);
    vector<ll> a(n + 5), pref(n + 5);
    vector<vector<ll>> dp(k + 5, vector<ll>(n + 5)), dp2(n + 5, vector<ll>(n + 5, -1e18));
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), pref[i] = pref[i - 1] + a[i];
    for (int i = 0; i <= n; i++) {
        dp2[i][i] = pref[i];
        for (int j = i + 1; j <= n; j++) dp2[i][j] = max(dp2[i][j - 1], pref[j]);
    }
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= n; j++) {
            for (int l = 0; l <= j; l++) dp[i][j] = max(dp[i][j], dp[i - 1][l] + dp2[l][j] - pref[l]);
        }
    }
    printf("%lld", *max_element(dp[k].begin(), dp[k].end()));
}

Compilation message

feast.cpp: In function 'int main()':
feast.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
feast.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), pref[i] = pref[i - 1] + a[i];
      |                                  ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 114 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 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 348 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 3 ms 1116 KB Output is correct
12 Correct 3 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 3 ms 1116 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 2 ms 856 KB Output is correct
17 Correct 3 ms 1112 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 3 ms 1116 KB Output is correct
12 Correct 3 ms 1116 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 3 ms 1116 KB Output is correct
15 Correct 2 ms 1116 KB Output is correct
16 Correct 2 ms 856 KB Output is correct
17 Correct 3 ms 1112 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 1116 KB Output is correct
21 Execution timed out 1008 ms 33112 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 114 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -