# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47849 | 2018-05-08T08:35:12 Z | Just_Solve_The_Problem | Candies (JOI18_candies) | C++11 | 7 ms | 1080 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 j = 1; j <= (n + 1) / 2; j++) { memset(dp[j & 1], 0, sizeof dp[j & 1]); for (int i = j * 2 - 1; i <= n; i++) { dp[j & 1][i] = dp[j & 1][i - 1]; dp[j & 1][i] = max(dp[j & 1][i], dp[j & 1 ^ 1][i - 2] + a[i]); } printf("%lld\n", dp[j & 1][n]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 508 KB | Output is correct |
3 | Correct | 6 ms | 612 KB | Output is correct |
4 | Correct | 6 ms | 612 KB | Output is correct |
5 | Correct | 6 ms | 676 KB | Output is correct |
6 | Correct | 6 ms | 760 KB | Output is correct |
7 | Correct | 6 ms | 760 KB | Output is correct |
8 | Correct | 6 ms | 760 KB | Output is correct |
9 | Correct | 6 ms | 768 KB | Output is correct |
10 | Correct | 6 ms | 788 KB | Output is correct |
11 | Correct | 6 ms | 808 KB | Output is correct |
12 | Correct | 6 ms | 828 KB | Output is correct |
13 | Correct | 6 ms | 848 KB | Output is correct |
14 | Correct | 6 ms | 996 KB | Output is correct |
15 | Correct | 7 ms | 996 KB | Output is correct |
16 | Correct | 6 ms | 1000 KB | Output is correct |
17 | Correct | 6 ms | 1028 KB | Output is correct |
18 | Correct | 6 ms | 1040 KB | Output is correct |
19 | Correct | 6 ms | 1060 KB | Output is correct |
20 | Correct | 6 ms | 1080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 508 KB | Output is correct |
3 | Correct | 6 ms | 612 KB | Output is correct |
4 | Correct | 6 ms | 612 KB | Output is correct |
5 | Correct | 6 ms | 676 KB | Output is correct |
6 | Correct | 6 ms | 760 KB | Output is correct |
7 | Correct | 6 ms | 760 KB | Output is correct |
8 | Correct | 6 ms | 760 KB | Output is correct |
9 | Correct | 6 ms | 768 KB | Output is correct |
10 | Correct | 6 ms | 788 KB | Output is correct |
11 | Correct | 6 ms | 808 KB | Output is correct |
12 | Correct | 6 ms | 828 KB | Output is correct |
13 | Correct | 6 ms | 848 KB | Output is correct |
14 | Correct | 6 ms | 996 KB | Output is correct |
15 | Correct | 7 ms | 996 KB | Output is correct |
16 | Correct | 6 ms | 1000 KB | Output is correct |
17 | Correct | 6 ms | 1028 KB | Output is correct |
18 | Correct | 6 ms | 1040 KB | Output is correct |
19 | Correct | 6 ms | 1060 KB | Output is correct |
20 | Correct | 6 ms | 1080 KB | Output is correct |
21 | Incorrect | 2 ms | 1080 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |