# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
172301 | 2020-01-01T05:14:54 Z | arnold518 | Candies (JOI18_candies) | C++14 | 35 ms | 31996 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; const ll INF = 1e16; int N, A[MAXN+10]; ll dp[MAXN+10][MAXN+10]; int main() { int i, j; scanf("%d", &N); for(i=1; i<=N; i++) scanf("%d", &A[i]); for(i=0; i<=N; i++) for(j=0; j<=N; j++) dp[i][j]=-INF; dp[1][1]=A[1]; for(i=0; i<=N; i++) dp[i][0]=0; for(i=2; i<=N; i++) { for(j=1; j<=(N+1)/2; j++) { dp[i][j]=max(dp[i-1][j], dp[i-2][j-1]+A[i]); } } for(i=1; i<=(N+1)/2; i++) printf("%lld\n", dp[N][i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 31992 KB | Output is correct |
2 | Correct | 30 ms | 31864 KB | Output is correct |
3 | Correct | 23 ms | 31868 KB | Output is correct |
4 | Correct | 29 ms | 31812 KB | Output is correct |
5 | Correct | 34 ms | 31864 KB | Output is correct |
6 | Correct | 30 ms | 31864 KB | Output is correct |
7 | Correct | 33 ms | 31864 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 29 ms | 31912 KB | Output is correct |
10 | Correct | 29 ms | 31864 KB | Output is correct |
11 | Correct | 29 ms | 31864 KB | Output is correct |
12 | Correct | 30 ms | 31864 KB | Output is correct |
13 | Correct | 34 ms | 31864 KB | Output is correct |
14 | Correct | 34 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31996 KB | Output is correct |
16 | Correct | 34 ms | 31864 KB | Output is correct |
17 | Correct | 34 ms | 31836 KB | Output is correct |
18 | Correct | 35 ms | 31864 KB | Output is correct |
19 | Correct | 33 ms | 31836 KB | Output is correct |
20 | Correct | 34 ms | 31864 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 31992 KB | Output is correct |
2 | Correct | 30 ms | 31864 KB | Output is correct |
3 | Correct | 23 ms | 31868 KB | Output is correct |
4 | Correct | 29 ms | 31812 KB | Output is correct |
5 | Correct | 34 ms | 31864 KB | Output is correct |
6 | Correct | 30 ms | 31864 KB | Output is correct |
7 | Correct | 33 ms | 31864 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 29 ms | 31912 KB | Output is correct |
10 | Correct | 29 ms | 31864 KB | Output is correct |
11 | Correct | 29 ms | 31864 KB | Output is correct |
12 | Correct | 30 ms | 31864 KB | Output is correct |
13 | Correct | 34 ms | 31864 KB | Output is correct |
14 | Correct | 34 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31996 KB | Output is correct |
16 | Correct | 34 ms | 31864 KB | Output is correct |
17 | Correct | 34 ms | 31836 KB | Output is correct |
18 | Correct | 35 ms | 31864 KB | Output is correct |
19 | Correct | 33 ms | 31836 KB | Output is correct |
20 | Correct | 34 ms | 31864 KB | Output is correct |
21 | Execution timed out | 4 ms | 632 KB | Time limit exceeded (wall clock) |
22 | Halted | 0 ms | 0 KB | - |