Submission #224733

# Submission time Handle Problem Language Result Execution time Memory
224733 2020-04-18T17:00:02 Z tictaccat Feast (NOI19_feast) C++14
18 / 100
1000 ms 2720 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N,K;
int A[500000];
int dp[2][2500];
int best[2][2500];

main() {

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

    for (int i = 0; i < N; i++) {
        for (int k = 1; k <= K; k++) {
            dp[i%2][k] = A[i] + max(dp[(i-1)%2][k],best[(i-1)%2][k-1]);
            best[i%2][k] = max(best[(i-1)%2][k], dp[i%2][k]);
        }
    }

    cout << best[(N-1)%2][K] << "\n";

}

Compilation message

feast.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 2684 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 194 ms 2720 KB Output is correct
2 Correct 187 ms 2604 KB Output is correct
3 Correct 191 ms 2680 KB Output is correct
4 Correct 202 ms 2680 KB Output is correct
5 Correct 196 ms 2680 KB Output is correct
6 Correct 201 ms 2656 KB Output is correct
7 Correct 203 ms 2680 KB Output is correct
8 Correct 190 ms 2680 KB Output is correct
9 Correct 195 ms 2704 KB Output is correct
10 Correct 197 ms 2708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 2684 KB Time limit exceeded
2 Halted 0 ms 0 KB -