# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
486581 |
2021-11-12T04:45:46 Z |
ez_ioi |
Candies (JOI18_candies) |
C++17 |
|
15 ms |
23116 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = 2e3 + 5, mod = 1e9 + 7, LOG = 20;
const ll inf = 1e18;
int n;
ll a[mxN], dp[mxN][mxN];
int main() {
ios :: sync_with_stdio(false), cin.tie(nullptr);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i; ++j) dp[i][j] = -inf;
}
for (int i = 1; i <= n; ++i) {
dp[i][1] = max(dp[i - 1][1], a[i]);
for (int j = 2; j <= i && i - j > 0; ++j)
dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]);
}
for (int i = 1; i <= (n + 1) / 2; ++i) cout << dp[n][i] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
22988 KB |
Output is correct |
2 |
Correct |
12 ms |
23040 KB |
Output is correct |
3 |
Correct |
12 ms |
22996 KB |
Output is correct |
4 |
Correct |
12 ms |
22988 KB |
Output is correct |
5 |
Correct |
14 ms |
23048 KB |
Output is correct |
6 |
Correct |
12 ms |
22988 KB |
Output is correct |
7 |
Correct |
12 ms |
22964 KB |
Output is correct |
8 |
Correct |
13 ms |
23048 KB |
Output is correct |
9 |
Correct |
14 ms |
22956 KB |
Output is correct |
10 |
Correct |
12 ms |
22988 KB |
Output is correct |
11 |
Correct |
12 ms |
22988 KB |
Output is correct |
12 |
Correct |
12 ms |
23024 KB |
Output is correct |
13 |
Correct |
15 ms |
22988 KB |
Output is correct |
14 |
Correct |
12 ms |
23116 KB |
Output is correct |
15 |
Correct |
12 ms |
23012 KB |
Output is correct |
16 |
Correct |
12 ms |
22988 KB |
Output is correct |
17 |
Correct |
12 ms |
23048 KB |
Output is correct |
18 |
Correct |
12 ms |
22956 KB |
Output is correct |
19 |
Correct |
12 ms |
22976 KB |
Output is correct |
20 |
Correct |
12 ms |
22988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
22988 KB |
Output is correct |
2 |
Correct |
12 ms |
23040 KB |
Output is correct |
3 |
Correct |
12 ms |
22996 KB |
Output is correct |
4 |
Correct |
12 ms |
22988 KB |
Output is correct |
5 |
Correct |
14 ms |
23048 KB |
Output is correct |
6 |
Correct |
12 ms |
22988 KB |
Output is correct |
7 |
Correct |
12 ms |
22964 KB |
Output is correct |
8 |
Correct |
13 ms |
23048 KB |
Output is correct |
9 |
Correct |
14 ms |
22956 KB |
Output is correct |
10 |
Correct |
12 ms |
22988 KB |
Output is correct |
11 |
Correct |
12 ms |
22988 KB |
Output is correct |
12 |
Correct |
12 ms |
23024 KB |
Output is correct |
13 |
Correct |
15 ms |
22988 KB |
Output is correct |
14 |
Correct |
12 ms |
23116 KB |
Output is correct |
15 |
Correct |
12 ms |
23012 KB |
Output is correct |
16 |
Correct |
12 ms |
22988 KB |
Output is correct |
17 |
Correct |
12 ms |
23048 KB |
Output is correct |
18 |
Correct |
12 ms |
22956 KB |
Output is correct |
19 |
Correct |
12 ms |
22976 KB |
Output is correct |
20 |
Correct |
12 ms |
22988 KB |
Output is correct |
21 |
Runtime error |
1 ms |
588 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |