Submission #224733

#TimeUsernameProblemLanguageResultExecution timeMemory
224733tictaccatFeast (NOI19_feast)C++14
18 / 100
1095 ms2720 KiB
#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 (stderr)

feast.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...