# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
528941 |
2022-02-21T19:21:13 Z |
tabr |
Mountains (IOI17_mountains) |
C++17 |
|
1000 ms |
16056 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
int maximum_deevs(vector<int> y) {
int n = (int) y.size();
vector<vector<int>> dp(n + 1, vector<int>(n + 1));
for (int l = n - 1; l >= 0; l--) {
for (int r = l + 1; r <= n; r++) {
int pos = (int) (max_element(y.begin() + l, y.begin() + r) - y.begin());
dp[l][r] = 1;
int lst = pos;
pair<int, int> a = make_pair(1, 0);
for (int i = pos - 1; i >= l; i--) {
auto b = make_pair(y[pos] - y[i], pos - i);
if (1LL * a.first * b.second >= 1LL * a.second * b.first) {
a = b;
dp[l][r] += dp[i + 1][lst];
lst = i;
}
}
dp[l][r] += dp[l][lst];
lst = pos;
a = make_pair(1, 0);
for (int i = pos + 1; i < r; i++) {
auto b = make_pair(y[pos] - y[i], i - pos);
if (1LL * a.first * b.second >= 1LL * a.second * b.first) {
a = b;
dp[l][r] += dp[lst + 1][i];
lst = i;
}
}
dp[l][r] += dp[lst + 1][r];
dp[l][r] = max(dp[l][r], dp[l][pos] + dp[pos + 1][r]);
}
}
return dp[0][n];
}
#ifdef tabr
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
debug(maximum_deevs({6, 1, 5, 2, 3, 1}));
debug(maximum_deevs({0, 1, 2}));
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
292 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
288 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
292 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
288 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
292 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
296 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
292 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
288 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
292 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
296 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
6 ms |
432 KB |
Output is correct |
40 |
Correct |
18 ms |
588 KB |
Output is correct |
41 |
Correct |
17 ms |
588 KB |
Output is correct |
42 |
Correct |
20 ms |
656 KB |
Output is correct |
43 |
Correct |
19 ms |
588 KB |
Output is correct |
44 |
Correct |
19 ms |
588 KB |
Output is correct |
45 |
Correct |
24 ms |
588 KB |
Output is correct |
46 |
Correct |
27 ms |
588 KB |
Output is correct |
47 |
Correct |
22 ms |
588 KB |
Output is correct |
48 |
Correct |
21 ms |
588 KB |
Output is correct |
49 |
Correct |
22 ms |
588 KB |
Output is correct |
50 |
Correct |
22 ms |
548 KB |
Output is correct |
51 |
Correct |
19 ms |
588 KB |
Output is correct |
52 |
Correct |
23 ms |
588 KB |
Output is correct |
53 |
Correct |
24 ms |
588 KB |
Output is correct |
54 |
Correct |
29 ms |
588 KB |
Output is correct |
55 |
Correct |
27 ms |
588 KB |
Output is correct |
56 |
Correct |
24 ms |
644 KB |
Output is correct |
57 |
Correct |
21 ms |
548 KB |
Output is correct |
58 |
Correct |
19 ms |
588 KB |
Output is correct |
59 |
Correct |
19 ms |
588 KB |
Output is correct |
60 |
Correct |
18 ms |
588 KB |
Output is correct |
61 |
Correct |
21 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
292 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
288 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
292 KB |
Output is correct |
23 |
Correct |
1 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
204 KB |
Output is correct |
26 |
Correct |
1 ms |
204 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
296 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
6 ms |
432 KB |
Output is correct |
40 |
Correct |
18 ms |
588 KB |
Output is correct |
41 |
Correct |
17 ms |
588 KB |
Output is correct |
42 |
Correct |
20 ms |
656 KB |
Output is correct |
43 |
Correct |
19 ms |
588 KB |
Output is correct |
44 |
Correct |
19 ms |
588 KB |
Output is correct |
45 |
Correct |
24 ms |
588 KB |
Output is correct |
46 |
Correct |
27 ms |
588 KB |
Output is correct |
47 |
Correct |
22 ms |
588 KB |
Output is correct |
48 |
Correct |
21 ms |
588 KB |
Output is correct |
49 |
Correct |
22 ms |
588 KB |
Output is correct |
50 |
Correct |
22 ms |
548 KB |
Output is correct |
51 |
Correct |
19 ms |
588 KB |
Output is correct |
52 |
Correct |
23 ms |
588 KB |
Output is correct |
53 |
Correct |
24 ms |
588 KB |
Output is correct |
54 |
Correct |
29 ms |
588 KB |
Output is correct |
55 |
Correct |
27 ms |
588 KB |
Output is correct |
56 |
Correct |
24 ms |
644 KB |
Output is correct |
57 |
Correct |
21 ms |
548 KB |
Output is correct |
58 |
Correct |
19 ms |
588 KB |
Output is correct |
59 |
Correct |
19 ms |
588 KB |
Output is correct |
60 |
Correct |
18 ms |
588 KB |
Output is correct |
61 |
Correct |
21 ms |
588 KB |
Output is correct |
62 |
Correct |
632 ms |
4244 KB |
Output is correct |
63 |
Execution timed out |
1067 ms |
16056 KB |
Time limit exceeded |
64 |
Halted |
0 ms |
0 KB |
- |