Submission #1017397

# Submission time Handle Problem Language Result Execution time Memory
1017397 2024-07-09T07:45:01 Z vjudge1 Feast (NOI19_feast) C++17
0 / 100
1000 ms 262144 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    //not uy tins
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<vector<int>> dp(K + 1, vector<int>(N + 1, 0));
    vector<int> prefixSum(N + 1, 0);

    for (int i = 1; i <= N; ++i) {
        prefixSum[i] = prefixSum[i - 1] + A[i - 1];
    }

    for (int k = 1; k <= K; ++k) {
        for (int n = 1; n <= N; ++n) {
            dp[k][n] = dp[k][n - 1];
            for (int i = 0; i < n; ++i) {
                dp[k][n] = max(dp[k][n], dp[k - 1][i] + prefixSum[n] - prefixSum[i]);
            }
        }
    }

    cout << dp[K][N] << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 189 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 4900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 5028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 189 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -