#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<vector<vector<int> > > dp(n + 1, vector<vector<int> > (n + 1, vector<int>(2, -INF)));
for(int i = 0;i <= n; i++){
dp[i][0][0] = 0;
}
vector<int> arr(n + 1, 0);
for(int i = 1; i <= n; i++)cin >> arr[i];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j][1]);
dp[i][j][1] = dp[i - 1][j - 1][0] + arr[i];
}
}
for(int i = 1; i <= (n + 1) / 2; i++)cout << max(dp[n][i][0], dp[n][i][1]) << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
219896 KB |
Output is correct |
2 |
Correct |
312 ms |
220052 KB |
Output is correct |
3 |
Correct |
310 ms |
220000 KB |
Output is correct |
4 |
Correct |
325 ms |
219896 KB |
Output is correct |
5 |
Correct |
312 ms |
220036 KB |
Output is correct |
6 |
Correct |
309 ms |
219896 KB |
Output is correct |
7 |
Correct |
309 ms |
219896 KB |
Output is correct |
8 |
Correct |
312 ms |
219900 KB |
Output is correct |
9 |
Correct |
311 ms |
220024 KB |
Output is correct |
10 |
Correct |
315 ms |
219896 KB |
Output is correct |
11 |
Correct |
311 ms |
219872 KB |
Output is correct |
12 |
Correct |
315 ms |
219768 KB |
Output is correct |
13 |
Correct |
304 ms |
219768 KB |
Output is correct |
14 |
Correct |
304 ms |
219772 KB |
Output is correct |
15 |
Correct |
312 ms |
219768 KB |
Output is correct |
16 |
Correct |
311 ms |
219768 KB |
Output is correct |
17 |
Correct |
310 ms |
219896 KB |
Output is correct |
18 |
Correct |
311 ms |
219768 KB |
Output is correct |
19 |
Correct |
307 ms |
219768 KB |
Output is correct |
20 |
Correct |
311 ms |
219768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
219896 KB |
Output is correct |
2 |
Correct |
312 ms |
220052 KB |
Output is correct |
3 |
Correct |
310 ms |
220000 KB |
Output is correct |
4 |
Correct |
325 ms |
219896 KB |
Output is correct |
5 |
Correct |
312 ms |
220036 KB |
Output is correct |
6 |
Correct |
309 ms |
219896 KB |
Output is correct |
7 |
Correct |
309 ms |
219896 KB |
Output is correct |
8 |
Correct |
312 ms |
219900 KB |
Output is correct |
9 |
Correct |
311 ms |
220024 KB |
Output is correct |
10 |
Correct |
315 ms |
219896 KB |
Output is correct |
11 |
Correct |
311 ms |
219872 KB |
Output is correct |
12 |
Correct |
315 ms |
219768 KB |
Output is correct |
13 |
Correct |
304 ms |
219768 KB |
Output is correct |
14 |
Correct |
304 ms |
219772 KB |
Output is correct |
15 |
Correct |
312 ms |
219768 KB |
Output is correct |
16 |
Correct |
311 ms |
219768 KB |
Output is correct |
17 |
Correct |
310 ms |
219896 KB |
Output is correct |
18 |
Correct |
311 ms |
219768 KB |
Output is correct |
19 |
Correct |
307 ms |
219768 KB |
Output is correct |
20 |
Correct |
311 ms |
219768 KB |
Output is correct |
21 |
Runtime error |
613 ms |
524292 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
22 |
Halted |
0 ms |
0 KB |
- |