# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
274239 | 2020-08-19T10:22:13 Z | Halit | Candies (JOI18_candies) | C++17 | 506 ms | 524292 KB |
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d", &n); vector<long long> v; for(int i = 0;i < n;++i){ long long c; scanf("%lld", &c); v.push_back(c); } vector< vector<long long> > dp(n+5, vector<long long>(n+5,-1)); function<long long(int, int)> DP = [&](int i, int j) -> long long{ if(i >= n || j <= 0) return (j > 0 ? -1e18 : 0); if(dp[i][j] != -1) return dp[i][j]; long long d = DP(i+1,j); if(j > 0) d = max(DP(i+2, j-1) + v[i], d); return dp[i][j] = d; }; for(int i = 1;i <= (n+1)/2;++i) printf("%lld\n", DP(0,i)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 105 ms | 32128 KB | Output is correct |
2 | Correct | 109 ms | 32256 KB | Output is correct |
3 | Correct | 108 ms | 32120 KB | Output is correct |
4 | Correct | 105 ms | 32128 KB | Output is correct |
5 | Correct | 107 ms | 32172 KB | Output is correct |
6 | Correct | 105 ms | 32128 KB | Output is correct |
7 | Correct | 107 ms | 32164 KB | Output is correct |
8 | Correct | 108 ms | 32128 KB | Output is correct |
9 | Correct | 104 ms | 32128 KB | Output is correct |
10 | Correct | 113 ms | 32128 KB | Output is correct |
11 | Correct | 109 ms | 32128 KB | Output is correct |
12 | Correct | 109 ms | 32120 KB | Output is correct |
13 | Correct | 106 ms | 32256 KB | Output is correct |
14 | Correct | 106 ms | 32128 KB | Output is correct |
15 | Correct | 111 ms | 32128 KB | Output is correct |
16 | Correct | 122 ms | 32248 KB | Output is correct |
17 | Correct | 111 ms | 32272 KB | Output is correct |
18 | Correct | 104 ms | 32128 KB | Output is correct |
19 | Correct | 109 ms | 32128 KB | Output is correct |
20 | Correct | 105 ms | 32128 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 105 ms | 32128 KB | Output is correct |
2 | Correct | 109 ms | 32256 KB | Output is correct |
3 | Correct | 108 ms | 32120 KB | Output is correct |
4 | Correct | 105 ms | 32128 KB | Output is correct |
5 | Correct | 107 ms | 32172 KB | Output is correct |
6 | Correct | 105 ms | 32128 KB | Output is correct |
7 | Correct | 107 ms | 32164 KB | Output is correct |
8 | Correct | 108 ms | 32128 KB | Output is correct |
9 | Correct | 104 ms | 32128 KB | Output is correct |
10 | Correct | 113 ms | 32128 KB | Output is correct |
11 | Correct | 109 ms | 32128 KB | Output is correct |
12 | Correct | 109 ms | 32120 KB | Output is correct |
13 | Correct | 106 ms | 32256 KB | Output is correct |
14 | Correct | 106 ms | 32128 KB | Output is correct |
15 | Correct | 111 ms | 32128 KB | Output is correct |
16 | Correct | 122 ms | 32248 KB | Output is correct |
17 | Correct | 111 ms | 32272 KB | Output is correct |
18 | Correct | 104 ms | 32128 KB | Output is correct |
19 | Correct | 109 ms | 32128 KB | Output is correct |
20 | Correct | 105 ms | 32128 KB | Output is correct |
21 | Runtime error | 506 ms | 524292 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |