# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47835 | 2018-05-08T05:44:46 Z | Just_Solve_The_Problem | Candies (JOI18_candies) | C++11 | 11 ms | 812 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = (int)1e5 + 7; const int smallN = (int)2e3 + 7; ll a[smallN], dp[2][smallN]; int n; main() { scanf("%d", &n); if (n > 2000) return 0; for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } for (int i = 1; i <= n; i++) { dp[1][i] = max(dp[1][i - 1], a[i]); } cout << dp[1][n] << endl; for (int j = 2; j <= (n + 1) / 2; j++) { memset(dp[j & 1], 0, sizeof dp[j & 1]); for (int i = j; i <= n; i++) { dp[j & 1][i] = dp[j & 1][i - 1]; if (i >= j * 2 - 1) dp[j & 1][i] = max(dp[j & 1][i], dp[j & 1 ^ 1][i - 2] + a[i]); } cout << dp[j & 1][n] << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 484 KB | Output is correct |
3 | Correct | 8 ms | 484 KB | Output is correct |
4 | Correct | 9 ms | 484 KB | Output is correct |
5 | Correct | 8 ms | 484 KB | Output is correct |
6 | Correct | 8 ms | 512 KB | Output is correct |
7 | Correct | 9 ms | 632 KB | Output is correct |
8 | Correct | 9 ms | 632 KB | Output is correct |
9 | Correct | 9 ms | 632 KB | Output is correct |
10 | Correct | 8 ms | 632 KB | Output is correct |
11 | Correct | 8 ms | 632 KB | Output is correct |
12 | Correct | 11 ms | 632 KB | Output is correct |
13 | Correct | 9 ms | 684 KB | Output is correct |
14 | Correct | 8 ms | 812 KB | Output is correct |
15 | Correct | 8 ms | 812 KB | Output is correct |
16 | Correct | 9 ms | 812 KB | Output is correct |
17 | Correct | 9 ms | 812 KB | Output is correct |
18 | Correct | 9 ms | 812 KB | Output is correct |
19 | Correct | 9 ms | 812 KB | Output is correct |
20 | Correct | 10 ms | 812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 484 KB | Output is correct |
3 | Correct | 8 ms | 484 KB | Output is correct |
4 | Correct | 9 ms | 484 KB | Output is correct |
5 | Correct | 8 ms | 484 KB | Output is correct |
6 | Correct | 8 ms | 512 KB | Output is correct |
7 | Correct | 9 ms | 632 KB | Output is correct |
8 | Correct | 9 ms | 632 KB | Output is correct |
9 | Correct | 9 ms | 632 KB | Output is correct |
10 | Correct | 8 ms | 632 KB | Output is correct |
11 | Correct | 8 ms | 632 KB | Output is correct |
12 | Correct | 11 ms | 632 KB | Output is correct |
13 | Correct | 9 ms | 684 KB | Output is correct |
14 | Correct | 8 ms | 812 KB | Output is correct |
15 | Correct | 8 ms | 812 KB | Output is correct |
16 | Correct | 9 ms | 812 KB | Output is correct |
17 | Correct | 9 ms | 812 KB | Output is correct |
18 | Correct | 9 ms | 812 KB | Output is correct |
19 | Correct | 9 ms | 812 KB | Output is correct |
20 | Correct | 10 ms | 812 KB | Output is correct |
21 | Incorrect | 2 ms | 812 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |