# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96720 | 2019-02-11T14:39:51 Z | Retro3014 | Candies (JOI18_candies) | C++17 | 33 ms | 24056 KB |
#include <iostream> #include <vector> #include <algorithm> #include <stdio.h> using namespace std; #define MAX_N 2000 #define INF 1000000000000000000LL typedef long long ll; int N; vector<ll> v; ll dp[MAX_N+1][MAX_N+1]; int main(){ scanf("%d", &N); for(int i=0; i<N; i++){ ll x; scanf("%lld", &x); v.push_back(x); } for(int i=0; i<N; i++){ for(int j=1; j<=((N+1)/2); j++){ dp[i][j] = -INF; } } for(int i=0; i<N; i++){ for(int j=1; j<=((i+2)/2); j++){ if(i<=1){ dp[i][j] = v[i]; }else{ dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+v[i]); } } } for(int i=1; i<=(N+1)/2; i++){ ll ans = -INF; for(int j=0; j<N; j++){ ans = max(ans, dp[j][i]); } printf("%lld\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 24056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 33 ms | 24056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |