# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
101306 |
2019-03-18T10:28:26 Z |
b2563125 |
Candies (JOI18_candies) |
C++14 |
|
715 ms |
525312 KB |
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<int>
#define vvel vector<vel>
#define vvvel vector<vvel>
#define veb vector<bool>
void mmax(int &a, int b) { a = max(a, b); }
vel ret_normal(int st, int to, vel &a) {
int siz = to - st;
int ko = (siz + 3) / 2;
vvel dp(siz+1, vel(ko, -1));
dp[0][0] = 0;
dp[1][0] = 0; dp[1][1] = a[st];
for (int i = 2; i <= siz; i++) {
dp[i] = dp[i - 1];
for (int j = 1; j < ko; j++) {
if (dp[i - 2][j - 1] != -1) { mmax(dp[i][j], dp[i - 2][j - 1] + a[st + i - 1]); }
}
}
return dp[siz];
}
signed main() {
int n; cin >> n;
vel a(n);
for (int i = 0; i < n; i++) { cin >> a[i]; }
vel ans((n + 3) / 2);
ans=ret_normal(0, n, a);
for (int i = 1; i < ans.size(); i++) { cout << ans[i] << endl; }
return 0;
}
Compilation message
candies.cpp: In function 'int main()':
candies.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < ans.size(); i++) { cout << ans[i] << endl; }
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
16128 KB |
Output is correct |
2 |
Correct |
27 ms |
16128 KB |
Output is correct |
3 |
Correct |
24 ms |
16144 KB |
Output is correct |
4 |
Correct |
30 ms |
16128 KB |
Output is correct |
5 |
Correct |
26 ms |
16128 KB |
Output is correct |
6 |
Correct |
24 ms |
16128 KB |
Output is correct |
7 |
Correct |
26 ms |
16132 KB |
Output is correct |
8 |
Correct |
27 ms |
16120 KB |
Output is correct |
9 |
Correct |
25 ms |
16104 KB |
Output is correct |
10 |
Correct |
26 ms |
16256 KB |
Output is correct |
11 |
Correct |
30 ms |
16072 KB |
Output is correct |
12 |
Correct |
26 ms |
16128 KB |
Output is correct |
13 |
Correct |
24 ms |
16256 KB |
Output is correct |
14 |
Correct |
26 ms |
16128 KB |
Output is correct |
15 |
Correct |
25 ms |
16128 KB |
Output is correct |
16 |
Correct |
25 ms |
16128 KB |
Output is correct |
17 |
Correct |
28 ms |
16128 KB |
Output is correct |
18 |
Correct |
25 ms |
16128 KB |
Output is correct |
19 |
Correct |
28 ms |
16248 KB |
Output is correct |
20 |
Correct |
28 ms |
16256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
16128 KB |
Output is correct |
2 |
Correct |
27 ms |
16128 KB |
Output is correct |
3 |
Correct |
24 ms |
16144 KB |
Output is correct |
4 |
Correct |
30 ms |
16128 KB |
Output is correct |
5 |
Correct |
26 ms |
16128 KB |
Output is correct |
6 |
Correct |
24 ms |
16128 KB |
Output is correct |
7 |
Correct |
26 ms |
16132 KB |
Output is correct |
8 |
Correct |
27 ms |
16120 KB |
Output is correct |
9 |
Correct |
25 ms |
16104 KB |
Output is correct |
10 |
Correct |
26 ms |
16256 KB |
Output is correct |
11 |
Correct |
30 ms |
16072 KB |
Output is correct |
12 |
Correct |
26 ms |
16128 KB |
Output is correct |
13 |
Correct |
24 ms |
16256 KB |
Output is correct |
14 |
Correct |
26 ms |
16128 KB |
Output is correct |
15 |
Correct |
25 ms |
16128 KB |
Output is correct |
16 |
Correct |
25 ms |
16128 KB |
Output is correct |
17 |
Correct |
28 ms |
16128 KB |
Output is correct |
18 |
Correct |
25 ms |
16128 KB |
Output is correct |
19 |
Correct |
28 ms |
16248 KB |
Output is correct |
20 |
Correct |
28 ms |
16256 KB |
Output is correct |
21 |
Runtime error |
715 ms |
525312 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
22 |
Halted |
0 ms |
0 KB |
- |