# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798950 |
2023-07-31T07:56:44 Z |
vjudge1 |
Candies (JOI18_candies) |
C++17 |
|
405 ms |
41560 KB |
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll dp[1111][2222], arr[2222];
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
for(int i = 1; i <= n; ++ i) {
cin >> arr[i];
}
for(int j = 1; j <= (n + 1) / 2; ++ j) {
for(int i = 2 * j - 1; i <= n; ++ i) {
dp[j][i] = max(dp[j][i - 1], (i > 1 ? dp[j - 1][i - 2] : 0) + arr[i]);
}
cout << dp[j][n] << '\n';
}
}
Compilation message
candies.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
12004 KB |
Output is correct |
2 |
Correct |
7 ms |
12004 KB |
Output is correct |
3 |
Correct |
7 ms |
12032 KB |
Output is correct |
4 |
Correct |
7 ms |
11992 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
7 ms |
11988 KB |
Output is correct |
7 |
Correct |
7 ms |
12060 KB |
Output is correct |
8 |
Correct |
7 ms |
11956 KB |
Output is correct |
9 |
Correct |
7 ms |
11992 KB |
Output is correct |
10 |
Correct |
7 ms |
11988 KB |
Output is correct |
11 |
Correct |
7 ms |
11992 KB |
Output is correct |
12 |
Correct |
6 ms |
11988 KB |
Output is correct |
13 |
Correct |
7 ms |
11936 KB |
Output is correct |
14 |
Correct |
7 ms |
11988 KB |
Output is correct |
15 |
Correct |
7 ms |
11988 KB |
Output is correct |
16 |
Correct |
7 ms |
11988 KB |
Output is correct |
17 |
Correct |
7 ms |
11988 KB |
Output is correct |
18 |
Correct |
7 ms |
11988 KB |
Output is correct |
19 |
Correct |
7 ms |
12004 KB |
Output is correct |
20 |
Correct |
7 ms |
11988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
12004 KB |
Output is correct |
2 |
Correct |
7 ms |
12004 KB |
Output is correct |
3 |
Correct |
7 ms |
12032 KB |
Output is correct |
4 |
Correct |
7 ms |
11992 KB |
Output is correct |
5 |
Correct |
7 ms |
11988 KB |
Output is correct |
6 |
Correct |
7 ms |
11988 KB |
Output is correct |
7 |
Correct |
7 ms |
12060 KB |
Output is correct |
8 |
Correct |
7 ms |
11956 KB |
Output is correct |
9 |
Correct |
7 ms |
11992 KB |
Output is correct |
10 |
Correct |
7 ms |
11988 KB |
Output is correct |
11 |
Correct |
7 ms |
11992 KB |
Output is correct |
12 |
Correct |
6 ms |
11988 KB |
Output is correct |
13 |
Correct |
7 ms |
11936 KB |
Output is correct |
14 |
Correct |
7 ms |
11988 KB |
Output is correct |
15 |
Correct |
7 ms |
11988 KB |
Output is correct |
16 |
Correct |
7 ms |
11988 KB |
Output is correct |
17 |
Correct |
7 ms |
11988 KB |
Output is correct |
18 |
Correct |
7 ms |
11988 KB |
Output is correct |
19 |
Correct |
7 ms |
12004 KB |
Output is correct |
20 |
Correct |
7 ms |
11988 KB |
Output is correct |
21 |
Runtime error |
405 ms |
41560 KB |
Execution killed with signal 11 |
22 |
Halted |
0 ms |
0 KB |
- |