#include <bits/stdc++.h>
using namespace std;
int tree[200500], n, h, v[200500], dp[200500];
void update(int p, int v) {
for(p++; p<200500; p+=p&-p) tree[p] = max(tree[p], v);
}
int query(int p) {
int ans = 0;
for(p++; p>0; p-=p&-p) ans = max(ans, tree[p]);
return ans;
}
int main() {
cin >> n >> h;
set<int> s;
for(int i=1; i<=n; i++) cin >> v[i], v[i] = 1ll * h * i - v[i];
for(int i=0; i<=n; i++) s.insert(v[i]);
vector<int> comp(s.begin(), s.end());
for(int i=1; i<=n; i++) {
int p = lower_bound(comp.begin(), comp.end(), v[i]) - comp.begin();
if(v[i] >= 0) dp[i] = query(p) + 1;
if(v[i] >= 0) update(p, dp[i]);
}
cout << n - query(n+5) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2496 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2496 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2648 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
2 ms |
2496 KB |
Output is correct |
21 |
Correct |
2 ms |
2648 KB |
Output is correct |
22 |
Correct |
2 ms |
2652 KB |
Output is correct |
23 |
Correct |
2 ms |
2648 KB |
Output is correct |
24 |
Correct |
2 ms |
2652 KB |
Output is correct |
25 |
Correct |
2 ms |
2652 KB |
Output is correct |
26 |
Correct |
2 ms |
2652 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
2 ms |
2396 KB |
Output is correct |
29 |
Correct |
2 ms |
2904 KB |
Output is correct |
30 |
Correct |
2 ms |
2776 KB |
Output is correct |
31 |
Correct |
2 ms |
2504 KB |
Output is correct |
32 |
Correct |
3 ms |
2652 KB |
Output is correct |
33 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
2 ms |
2496 KB |
Output is correct |
5 |
Correct |
2 ms |
2648 KB |
Output is correct |
6 |
Correct |
2 ms |
2652 KB |
Output is correct |
7 |
Correct |
2 ms |
2648 KB |
Output is correct |
8 |
Correct |
2 ms |
2652 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
2 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2904 KB |
Output is correct |
14 |
Correct |
2 ms |
2776 KB |
Output is correct |
15 |
Correct |
2 ms |
2504 KB |
Output is correct |
16 |
Correct |
3 ms |
2652 KB |
Output is correct |
17 |
Correct |
2 ms |
2652 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2496 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2392 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
2392 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2392 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
33 |
Correct |
1 ms |
2648 KB |
Output is correct |
34 |
Correct |
3 ms |
2796 KB |
Output is correct |
35 |
Correct |
3 ms |
2648 KB |
Output is correct |
36 |
Correct |
3 ms |
2652 KB |
Output is correct |
37 |
Correct |
2 ms |
2764 KB |
Output is correct |
38 |
Correct |
2 ms |
2396 KB |
Output is correct |
39 |
Correct |
2 ms |
2396 KB |
Output is correct |
40 |
Correct |
2 ms |
2652 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
2 ms |
2652 KB |
Output is correct |
43 |
Correct |
3 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2796 KB |
Output is correct |
2 |
Correct |
3 ms |
2648 KB |
Output is correct |
3 |
Correct |
3 ms |
2652 KB |
Output is correct |
4 |
Correct |
2 ms |
2764 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
2 ms |
2652 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
2 ms |
2652 KB |
Output is correct |
10 |
Correct |
3 ms |
2648 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
2 ms |
2496 KB |
Output is correct |
15 |
Correct |
2 ms |
2648 KB |
Output is correct |
16 |
Correct |
2 ms |
2652 KB |
Output is correct |
17 |
Correct |
2 ms |
2648 KB |
Output is correct |
18 |
Correct |
2 ms |
2652 KB |
Output is correct |
19 |
Correct |
2 ms |
2652 KB |
Output is correct |
20 |
Correct |
2 ms |
2652 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
2 ms |
2396 KB |
Output is correct |
23 |
Correct |
2 ms |
2904 KB |
Output is correct |
24 |
Correct |
2 ms |
2776 KB |
Output is correct |
25 |
Correct |
2 ms |
2504 KB |
Output is correct |
26 |
Correct |
3 ms |
2652 KB |
Output is correct |
27 |
Correct |
2 ms |
2652 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2496 KB |
Output is correct |
31 |
Correct |
1 ms |
2396 KB |
Output is correct |
32 |
Correct |
0 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2392 KB |
Output is correct |
34 |
Correct |
1 ms |
2396 KB |
Output is correct |
35 |
Correct |
1 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2392 KB |
Output is correct |
37 |
Correct |
0 ms |
2396 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
1 ms |
2392 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
1 ms |
2392 KB |
Output is correct |
43 |
Correct |
1 ms |
2648 KB |
Output is correct |
44 |
Correct |
73 ms |
13352 KB |
Output is correct |
45 |
Correct |
133 ms |
14420 KB |
Output is correct |
46 |
Correct |
136 ms |
14856 KB |
Output is correct |
47 |
Correct |
139 ms |
14744 KB |
Output is correct |
48 |
Correct |
80 ms |
13396 KB |
Output is correct |
49 |
Correct |
81 ms |
13908 KB |
Output is correct |
50 |
Correct |
60 ms |
4432 KB |
Output is correct |
51 |
Correct |
60 ms |
4372 KB |
Output is correct |
52 |
Correct |
65 ms |
8660 KB |
Output is correct |
53 |
Correct |
40 ms |
3676 KB |
Output is correct |
54 |
Correct |
80 ms |
13804 KB |
Output is correct |
55 |
Correct |
88 ms |
13648 KB |
Output is correct |