#include <bits/stdc++.h>
#include "mountains.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2018;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
int N;
int dp[MAXN][MAXN], A[MAXN];
int maximum_deevs (vector<int> v) {
N = v.size();
copy(all(v), A);
for (int rt = 0; rt < N; rt++) {
dp[rt][rt] = 1;
int block = rt; //which one IS BLOCKING others?
int notsee = 0; //which one you guarantee not see?
for (int lt = rt - 1; lt >= 0; lt--) {
dp[lt][rt] = dp[lt][rt - 1];
ll dx1 = block - lt, dy1 = A[block] - A[lt], dx2 = rt - lt, dy2 = A[rt] - A[lt];
if (dx1 * dy2 >= dx2 * dy1) {
if (lt + 1 <= block - 1) {
notsee += dp[lt + 1][block - 1];
}
block = lt;
}
dp[lt][rt] = max(dp[lt][rt], notsee + 1 + (lt < block ? dp[lt][block - 1] : 0));
}
}
return dp[0][N - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
4 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
0 ms |
744 KB |
Output is correct |
11 |
Correct |
2 ms |
744 KB |
Output is correct |
12 |
Correct |
3 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
3 ms |
792 KB |
Output is correct |
15 |
Correct |
3 ms |
792 KB |
Output is correct |
16 |
Correct |
3 ms |
792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
4 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
0 ms |
744 KB |
Output is correct |
11 |
Correct |
2 ms |
744 KB |
Output is correct |
12 |
Correct |
3 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
3 ms |
792 KB |
Output is correct |
15 |
Correct |
3 ms |
792 KB |
Output is correct |
16 |
Correct |
3 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
3 ms |
884 KB |
Output is correct |
19 |
Correct |
3 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
896 KB |
Output is correct |
21 |
Correct |
4 ms |
896 KB |
Output is correct |
22 |
Correct |
3 ms |
900 KB |
Output is correct |
23 |
Correct |
4 ms |
904 KB |
Output is correct |
24 |
Correct |
2 ms |
908 KB |
Output is correct |
25 |
Correct |
3 ms |
912 KB |
Output is correct |
26 |
Correct |
3 ms |
916 KB |
Output is correct |
27 |
Correct |
3 ms |
920 KB |
Output is correct |
28 |
Correct |
3 ms |
920 KB |
Output is correct |
29 |
Correct |
2 ms |
928 KB |
Output is correct |
30 |
Correct |
3 ms |
932 KB |
Output is correct |
31 |
Correct |
3 ms |
956 KB |
Output is correct |
32 |
Correct |
3 ms |
1056 KB |
Output is correct |
33 |
Correct |
3 ms |
1056 KB |
Output is correct |
34 |
Correct |
3 ms |
1056 KB |
Output is correct |
35 |
Correct |
4 ms |
1056 KB |
Output is correct |
36 |
Correct |
2 ms |
1056 KB |
Output is correct |
37 |
Correct |
3 ms |
1056 KB |
Output is correct |
38 |
Correct |
3 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
4 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
0 ms |
744 KB |
Output is correct |
11 |
Correct |
2 ms |
744 KB |
Output is correct |
12 |
Correct |
3 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
3 ms |
792 KB |
Output is correct |
15 |
Correct |
3 ms |
792 KB |
Output is correct |
16 |
Correct |
3 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
3 ms |
884 KB |
Output is correct |
19 |
Correct |
3 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
896 KB |
Output is correct |
21 |
Correct |
4 ms |
896 KB |
Output is correct |
22 |
Correct |
3 ms |
900 KB |
Output is correct |
23 |
Correct |
4 ms |
904 KB |
Output is correct |
24 |
Correct |
2 ms |
908 KB |
Output is correct |
25 |
Correct |
3 ms |
912 KB |
Output is correct |
26 |
Correct |
3 ms |
916 KB |
Output is correct |
27 |
Correct |
3 ms |
920 KB |
Output is correct |
28 |
Correct |
3 ms |
920 KB |
Output is correct |
29 |
Correct |
2 ms |
928 KB |
Output is correct |
30 |
Correct |
3 ms |
932 KB |
Output is correct |
31 |
Correct |
3 ms |
956 KB |
Output is correct |
32 |
Correct |
3 ms |
1056 KB |
Output is correct |
33 |
Correct |
3 ms |
1056 KB |
Output is correct |
34 |
Correct |
3 ms |
1056 KB |
Output is correct |
35 |
Correct |
4 ms |
1056 KB |
Output is correct |
36 |
Correct |
2 ms |
1056 KB |
Output is correct |
37 |
Correct |
3 ms |
1056 KB |
Output is correct |
38 |
Correct |
3 ms |
1056 KB |
Output is correct |
39 |
Correct |
4 ms |
1628 KB |
Output is correct |
40 |
Correct |
5 ms |
2144 KB |
Output is correct |
41 |
Correct |
6 ms |
2148 KB |
Output is correct |
42 |
Correct |
5 ms |
2184 KB |
Output is correct |
43 |
Correct |
4 ms |
2184 KB |
Output is correct |
44 |
Correct |
4 ms |
2184 KB |
Output is correct |
45 |
Correct |
4 ms |
2184 KB |
Output is correct |
46 |
Correct |
5 ms |
2184 KB |
Output is correct |
47 |
Correct |
4 ms |
2184 KB |
Output is correct |
48 |
Correct |
5 ms |
2184 KB |
Output is correct |
49 |
Correct |
5 ms |
2184 KB |
Output is correct |
50 |
Correct |
4 ms |
2184 KB |
Output is correct |
51 |
Correct |
4 ms |
2188 KB |
Output is correct |
52 |
Correct |
4 ms |
2192 KB |
Output is correct |
53 |
Correct |
4 ms |
2196 KB |
Output is correct |
54 |
Correct |
4 ms |
2200 KB |
Output is correct |
55 |
Correct |
4 ms |
2204 KB |
Output is correct |
56 |
Correct |
4 ms |
2208 KB |
Output is correct |
57 |
Correct |
4 ms |
2212 KB |
Output is correct |
58 |
Correct |
5 ms |
2216 KB |
Output is correct |
59 |
Correct |
4 ms |
2220 KB |
Output is correct |
60 |
Correct |
4 ms |
2224 KB |
Output is correct |
61 |
Correct |
3 ms |
2228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
3 ms |
668 KB |
Output is correct |
8 |
Correct |
4 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
0 ms |
744 KB |
Output is correct |
11 |
Correct |
2 ms |
744 KB |
Output is correct |
12 |
Correct |
3 ms |
744 KB |
Output is correct |
13 |
Correct |
3 ms |
744 KB |
Output is correct |
14 |
Correct |
3 ms |
792 KB |
Output is correct |
15 |
Correct |
3 ms |
792 KB |
Output is correct |
16 |
Correct |
3 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
880 KB |
Output is correct |
18 |
Correct |
3 ms |
884 KB |
Output is correct |
19 |
Correct |
3 ms |
888 KB |
Output is correct |
20 |
Correct |
3 ms |
896 KB |
Output is correct |
21 |
Correct |
4 ms |
896 KB |
Output is correct |
22 |
Correct |
3 ms |
900 KB |
Output is correct |
23 |
Correct |
4 ms |
904 KB |
Output is correct |
24 |
Correct |
2 ms |
908 KB |
Output is correct |
25 |
Correct |
3 ms |
912 KB |
Output is correct |
26 |
Correct |
3 ms |
916 KB |
Output is correct |
27 |
Correct |
3 ms |
920 KB |
Output is correct |
28 |
Correct |
3 ms |
920 KB |
Output is correct |
29 |
Correct |
2 ms |
928 KB |
Output is correct |
30 |
Correct |
3 ms |
932 KB |
Output is correct |
31 |
Correct |
3 ms |
956 KB |
Output is correct |
32 |
Correct |
3 ms |
1056 KB |
Output is correct |
33 |
Correct |
3 ms |
1056 KB |
Output is correct |
34 |
Correct |
3 ms |
1056 KB |
Output is correct |
35 |
Correct |
4 ms |
1056 KB |
Output is correct |
36 |
Correct |
2 ms |
1056 KB |
Output is correct |
37 |
Correct |
3 ms |
1056 KB |
Output is correct |
38 |
Correct |
3 ms |
1056 KB |
Output is correct |
39 |
Correct |
4 ms |
1628 KB |
Output is correct |
40 |
Correct |
5 ms |
2144 KB |
Output is correct |
41 |
Correct |
6 ms |
2148 KB |
Output is correct |
42 |
Correct |
5 ms |
2184 KB |
Output is correct |
43 |
Correct |
4 ms |
2184 KB |
Output is correct |
44 |
Correct |
4 ms |
2184 KB |
Output is correct |
45 |
Correct |
4 ms |
2184 KB |
Output is correct |
46 |
Correct |
5 ms |
2184 KB |
Output is correct |
47 |
Correct |
4 ms |
2184 KB |
Output is correct |
48 |
Correct |
5 ms |
2184 KB |
Output is correct |
49 |
Correct |
5 ms |
2184 KB |
Output is correct |
50 |
Correct |
4 ms |
2184 KB |
Output is correct |
51 |
Correct |
4 ms |
2188 KB |
Output is correct |
52 |
Correct |
4 ms |
2192 KB |
Output is correct |
53 |
Correct |
4 ms |
2196 KB |
Output is correct |
54 |
Correct |
4 ms |
2200 KB |
Output is correct |
55 |
Correct |
4 ms |
2204 KB |
Output is correct |
56 |
Correct |
4 ms |
2208 KB |
Output is correct |
57 |
Correct |
4 ms |
2212 KB |
Output is correct |
58 |
Correct |
5 ms |
2216 KB |
Output is correct |
59 |
Correct |
4 ms |
2220 KB |
Output is correct |
60 |
Correct |
4 ms |
2224 KB |
Output is correct |
61 |
Correct |
3 ms |
2228 KB |
Output is correct |
62 |
Correct |
15 ms |
6840 KB |
Output is correct |
63 |
Correct |
41 ms |
14860 KB |
Output is correct |
64 |
Correct |
41 ms |
14860 KB |
Output is correct |
65 |
Correct |
42 ms |
14860 KB |
Output is correct |
66 |
Correct |
38 ms |
14880 KB |
Output is correct |
67 |
Correct |
50 ms |
14900 KB |
Output is correct |
68 |
Correct |
43 ms |
14980 KB |
Output is correct |
69 |
Correct |
35 ms |
14980 KB |
Output is correct |
70 |
Correct |
36 ms |
14980 KB |
Output is correct |
71 |
Correct |
34 ms |
14992 KB |
Output is correct |
72 |
Correct |
41 ms |
15008 KB |
Output is correct |
73 |
Correct |
36 ms |
15168 KB |
Output is correct |
74 |
Correct |
36 ms |
15168 KB |
Output is correct |
75 |
Correct |
50 ms |
15168 KB |
Output is correct |
76 |
Correct |
47 ms |
15220 KB |
Output is correct |
77 |
Correct |
46 ms |
15220 KB |
Output is correct |
78 |
Correct |
35 ms |
15220 KB |
Output is correct |
79 |
Correct |
43 ms |
15220 KB |
Output is correct |
80 |
Correct |
40 ms |
15220 KB |
Output is correct |
81 |
Correct |
39 ms |
15220 KB |
Output is correct |
82 |
Correct |
53 ms |
15220 KB |
Output is correct |
83 |
Correct |
47 ms |
15320 KB |
Output is correct |
84 |
Correct |
43 ms |
15320 KB |
Output is correct |
85 |
Correct |
36 ms |
15320 KB |
Output is correct |
86 |
Correct |
41 ms |
15356 KB |
Output is correct |