# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1046942 |
2024-08-07T06:37:49 Z |
Sharky |
Candies (JOI18_candies) |
C++17 |
|
13 ms |
31860 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[2001], dp[2001][2001], mx[2001];
const int inf = 1e18;
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
mx[i] = max(mx[i - 1], a[i]);
}
for (int i = 0; i < 2001; i++) for (int j = 0; j < 2001; j++) dp[i][j] = -inf;
for (int i = 0; i <= n; i++) {
dp[i][0] = 0;
if (i >= 1) dp[i][1] = mx[i];
}
for (int j = 2; j <= n; j++) {
for (int i = 1; i <= n; i++) {
if (i >= 2) dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]);
else dp[i][j] = dp[i - 1][j];
}
}
for (int i = 1; i <= (n + 1) / 2; i++) cout << dp[n][i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
31836 KB |
Output is correct |
2 |
Correct |
11 ms |
31688 KB |
Output is correct |
3 |
Correct |
10 ms |
31848 KB |
Output is correct |
4 |
Correct |
10 ms |
31744 KB |
Output is correct |
5 |
Correct |
12 ms |
31656 KB |
Output is correct |
6 |
Correct |
10 ms |
31832 KB |
Output is correct |
7 |
Correct |
9 ms |
31836 KB |
Output is correct |
8 |
Correct |
10 ms |
31836 KB |
Output is correct |
9 |
Correct |
10 ms |
31740 KB |
Output is correct |
10 |
Correct |
10 ms |
31836 KB |
Output is correct |
11 |
Correct |
12 ms |
31704 KB |
Output is correct |
12 |
Correct |
10 ms |
31836 KB |
Output is correct |
13 |
Correct |
10 ms |
31836 KB |
Output is correct |
14 |
Correct |
11 ms |
31860 KB |
Output is correct |
15 |
Correct |
13 ms |
31836 KB |
Output is correct |
16 |
Correct |
10 ms |
31852 KB |
Output is correct |
17 |
Correct |
11 ms |
31836 KB |
Output is correct |
18 |
Correct |
10 ms |
31836 KB |
Output is correct |
19 |
Correct |
10 ms |
31836 KB |
Output is correct |
20 |
Correct |
10 ms |
31660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
31836 KB |
Output is correct |
2 |
Correct |
11 ms |
31688 KB |
Output is correct |
3 |
Correct |
10 ms |
31848 KB |
Output is correct |
4 |
Correct |
10 ms |
31744 KB |
Output is correct |
5 |
Correct |
12 ms |
31656 KB |
Output is correct |
6 |
Correct |
10 ms |
31832 KB |
Output is correct |
7 |
Correct |
9 ms |
31836 KB |
Output is correct |
8 |
Correct |
10 ms |
31836 KB |
Output is correct |
9 |
Correct |
10 ms |
31740 KB |
Output is correct |
10 |
Correct |
10 ms |
31836 KB |
Output is correct |
11 |
Correct |
12 ms |
31704 KB |
Output is correct |
12 |
Correct |
10 ms |
31836 KB |
Output is correct |
13 |
Correct |
10 ms |
31836 KB |
Output is correct |
14 |
Correct |
11 ms |
31860 KB |
Output is correct |
15 |
Correct |
13 ms |
31836 KB |
Output is correct |
16 |
Correct |
10 ms |
31852 KB |
Output is correct |
17 |
Correct |
11 ms |
31836 KB |
Output is correct |
18 |
Correct |
10 ms |
31836 KB |
Output is correct |
19 |
Correct |
10 ms |
31836 KB |
Output is correct |
20 |
Correct |
10 ms |
31660 KB |
Output is correct |
21 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |