#include <bits/stdc++.h>
using namespace std;
#define FILE "TEST"
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fi first
#define se second
long long dp[2022][2022], a[2022];
int n;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 0; i <= n; i++)
for (int j = 1; j <= n; j++) dp[i][j] = -9E18;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
dp[i][j] = max(dp[i - 1][j], dp[max(i - 2, 0)][j - 1] + a[i]);
for (int j = 1; j <= (n + 1) / 2; j++) cout << dp[n][j] << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
32088 KB |
Output is correct |
2 |
Correct |
8 ms |
31980 KB |
Output is correct |
3 |
Correct |
8 ms |
32188 KB |
Output is correct |
4 |
Correct |
8 ms |
32088 KB |
Output is correct |
5 |
Correct |
8 ms |
32092 KB |
Output is correct |
6 |
Correct |
8 ms |
32092 KB |
Output is correct |
7 |
Correct |
8 ms |
32092 KB |
Output is correct |
8 |
Correct |
8 ms |
32092 KB |
Output is correct |
9 |
Correct |
12 ms |
32168 KB |
Output is correct |
10 |
Correct |
8 ms |
32092 KB |
Output is correct |
11 |
Correct |
8 ms |
32088 KB |
Output is correct |
12 |
Correct |
8 ms |
32092 KB |
Output is correct |
13 |
Correct |
8 ms |
32152 KB |
Output is correct |
14 |
Correct |
8 ms |
32164 KB |
Output is correct |
15 |
Correct |
8 ms |
32164 KB |
Output is correct |
16 |
Correct |
8 ms |
32160 KB |
Output is correct |
17 |
Correct |
8 ms |
32092 KB |
Output is correct |
18 |
Correct |
8 ms |
32088 KB |
Output is correct |
19 |
Correct |
9 ms |
32092 KB |
Output is correct |
20 |
Correct |
10 ms |
32152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
32088 KB |
Output is correct |
2 |
Correct |
8 ms |
31980 KB |
Output is correct |
3 |
Correct |
8 ms |
32188 KB |
Output is correct |
4 |
Correct |
8 ms |
32088 KB |
Output is correct |
5 |
Correct |
8 ms |
32092 KB |
Output is correct |
6 |
Correct |
8 ms |
32092 KB |
Output is correct |
7 |
Correct |
8 ms |
32092 KB |
Output is correct |
8 |
Correct |
8 ms |
32092 KB |
Output is correct |
9 |
Correct |
12 ms |
32168 KB |
Output is correct |
10 |
Correct |
8 ms |
32092 KB |
Output is correct |
11 |
Correct |
8 ms |
32088 KB |
Output is correct |
12 |
Correct |
8 ms |
32092 KB |
Output is correct |
13 |
Correct |
8 ms |
32152 KB |
Output is correct |
14 |
Correct |
8 ms |
32164 KB |
Output is correct |
15 |
Correct |
8 ms |
32164 KB |
Output is correct |
16 |
Correct |
8 ms |
32160 KB |
Output is correct |
17 |
Correct |
8 ms |
32092 KB |
Output is correct |
18 |
Correct |
8 ms |
32088 KB |
Output is correct |
19 |
Correct |
9 ms |
32092 KB |
Output is correct |
20 |
Correct |
10 ms |
32152 KB |
Output is correct |
21 |
Runtime error |
161 ms |
67344 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |