# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237746 |
2020-06-08T14:57:09 Z |
Haunted_Cpp |
Feast (NOI19_feast) |
C++17 |
|
96 ms |
37496 KB |
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
bool calc [N][N][2];
long long dp [N][N][2];
long long arr [N];
int n, k;
long long solve (int p, int box, bool is) {
if (box < 0) return -1e15;
if (p >= n) return (box >= 0 ? 0 : -1e15);
if (calc[p][box][is]) return dp[p][box][is];
long long &res = dp[p][box][is];
calc[p][box][is] = true;
res = -1e15;
if (!is) {
res = max (res, solve (p + 1, box, false) );
res = max (res, solve (p + 1, box - 1, true) + arr[p]);
} else {
res = max (res, solve (p + 1, box, true) + arr[p]);
res = max (res, solve (p + 1, box, false) );
}
return res;
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
memset (calc, false, sizeof(calc));
cin >> n >> k;
for (int i = 0; i < n; i++) cin >> arr[i];
cout << solve (0, k, false) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
96 ms |
37240 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
74 ms |
37496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
96 ms |
37240 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8576 KB |
Output is correct |
2 |
Correct |
9 ms |
8576 KB |
Output is correct |
3 |
Correct |
9 ms |
8448 KB |
Output is correct |
4 |
Correct |
9 ms |
8576 KB |
Output is correct |
5 |
Correct |
9 ms |
8576 KB |
Output is correct |
6 |
Correct |
10 ms |
8576 KB |
Output is correct |
7 |
Correct |
9 ms |
8576 KB |
Output is correct |
8 |
Correct |
9 ms |
8576 KB |
Output is correct |
9 |
Correct |
9 ms |
8576 KB |
Output is correct |
10 |
Correct |
9 ms |
8448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8576 KB |
Output is correct |
2 |
Correct |
9 ms |
8576 KB |
Output is correct |
3 |
Correct |
9 ms |
8448 KB |
Output is correct |
4 |
Correct |
9 ms |
8576 KB |
Output is correct |
5 |
Correct |
9 ms |
8576 KB |
Output is correct |
6 |
Correct |
10 ms |
8576 KB |
Output is correct |
7 |
Correct |
9 ms |
8576 KB |
Output is correct |
8 |
Correct |
9 ms |
8576 KB |
Output is correct |
9 |
Correct |
9 ms |
8576 KB |
Output is correct |
10 |
Correct |
9 ms |
8448 KB |
Output is correct |
11 |
Correct |
10 ms |
9600 KB |
Output is correct |
12 |
Correct |
10 ms |
9472 KB |
Output is correct |
13 |
Correct |
9 ms |
9344 KB |
Output is correct |
14 |
Correct |
11 ms |
9600 KB |
Output is correct |
15 |
Correct |
11 ms |
9472 KB |
Output is correct |
16 |
Correct |
10 ms |
9344 KB |
Output is correct |
17 |
Correct |
9 ms |
9600 KB |
Output is correct |
18 |
Correct |
11 ms |
9312 KB |
Output is correct |
19 |
Correct |
11 ms |
9336 KB |
Output is correct |
20 |
Correct |
9 ms |
9472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8576 KB |
Output is correct |
2 |
Correct |
9 ms |
8576 KB |
Output is correct |
3 |
Correct |
9 ms |
8448 KB |
Output is correct |
4 |
Correct |
9 ms |
8576 KB |
Output is correct |
5 |
Correct |
9 ms |
8576 KB |
Output is correct |
6 |
Correct |
10 ms |
8576 KB |
Output is correct |
7 |
Correct |
9 ms |
8576 KB |
Output is correct |
8 |
Correct |
9 ms |
8576 KB |
Output is correct |
9 |
Correct |
9 ms |
8576 KB |
Output is correct |
10 |
Correct |
9 ms |
8448 KB |
Output is correct |
11 |
Correct |
10 ms |
9600 KB |
Output is correct |
12 |
Correct |
10 ms |
9472 KB |
Output is correct |
13 |
Correct |
9 ms |
9344 KB |
Output is correct |
14 |
Correct |
11 ms |
9600 KB |
Output is correct |
15 |
Correct |
11 ms |
9472 KB |
Output is correct |
16 |
Correct |
10 ms |
9344 KB |
Output is correct |
17 |
Correct |
9 ms |
9600 KB |
Output is correct |
18 |
Correct |
11 ms |
9312 KB |
Output is correct |
19 |
Correct |
11 ms |
9336 KB |
Output is correct |
20 |
Correct |
9 ms |
9472 KB |
Output is correct |
21 |
Correct |
31 ms |
21752 KB |
Output is correct |
22 |
Correct |
88 ms |
30840 KB |
Output is correct |
23 |
Correct |
65 ms |
25696 KB |
Output is correct |
24 |
Correct |
41 ms |
22136 KB |
Output is correct |
25 |
Correct |
52 ms |
24312 KB |
Output is correct |
26 |
Correct |
29 ms |
21376 KB |
Output is correct |
27 |
Correct |
45 ms |
23800 KB |
Output is correct |
28 |
Correct |
16 ms |
17408 KB |
Output is correct |
29 |
Correct |
16 ms |
17280 KB |
Output is correct |
30 |
Correct |
13 ms |
16256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
96 ms |
37240 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |