from typing import List
from bisect import bisect_right
def longest_nondec_subseq(arr: List[int]) -> int:
min_endings = []
for i in arr:
# bisect_right not left because it just has to be nondecreasing
pos = bisect_right(min_endings, i)
# standard LIS protocol
if pos == len(min_endings):
min_endings.append(i)
else:
min_endings[pos] = i
return len(min_endings)
pole_num, jump_height = [int(i) for i in input().split()]
poles = [int(input()) for _ in range(pole_num)]
poss_unchanged = []
for i, p in enumerate(poles):
if (i + 1) * jump_height >= p:
poss_unchanged.append((i + 1) * jump_height - p)
print(pole_num - longest_nondec_subseq(poss_unchanged))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
4204 KB |
Output is correct |
2 |
Correct |
29 ms |
4076 KB |
Output is correct |
3 |
Correct |
29 ms |
4076 KB |
Output is correct |
4 |
Correct |
29 ms |
4076 KB |
Output is correct |
5 |
Correct |
29 ms |
4076 KB |
Output is correct |
6 |
Correct |
29 ms |
4076 KB |
Output is correct |
7 |
Correct |
32 ms |
4076 KB |
Output is correct |
8 |
Correct |
33 ms |
4076 KB |
Output is correct |
9 |
Correct |
30 ms |
4076 KB |
Output is correct |
10 |
Correct |
30 ms |
4076 KB |
Output is correct |
11 |
Correct |
29 ms |
4076 KB |
Output is correct |
12 |
Correct |
30 ms |
4076 KB |
Output is correct |
13 |
Correct |
29 ms |
4076 KB |
Output is correct |
14 |
Correct |
29 ms |
4076 KB |
Output is correct |
15 |
Correct |
29 ms |
4096 KB |
Output is correct |
16 |
Correct |
30 ms |
4076 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
4204 KB |
Output is correct |
2 |
Correct |
29 ms |
4076 KB |
Output is correct |
3 |
Correct |
29 ms |
4076 KB |
Output is correct |
4 |
Correct |
29 ms |
4076 KB |
Output is correct |
5 |
Correct |
29 ms |
4076 KB |
Output is correct |
6 |
Correct |
29 ms |
4076 KB |
Output is correct |
7 |
Correct |
32 ms |
4076 KB |
Output is correct |
8 |
Correct |
33 ms |
4076 KB |
Output is correct |
9 |
Correct |
30 ms |
4076 KB |
Output is correct |
10 |
Correct |
30 ms |
4076 KB |
Output is correct |
11 |
Correct |
29 ms |
4076 KB |
Output is correct |
12 |
Correct |
30 ms |
4076 KB |
Output is correct |
13 |
Correct |
29 ms |
4076 KB |
Output is correct |
14 |
Correct |
29 ms |
4076 KB |
Output is correct |
15 |
Correct |
29 ms |
4096 KB |
Output is correct |
16 |
Correct |
30 ms |
4076 KB |
Output is correct |
17 |
Correct |
30 ms |
4076 KB |
Output is correct |
18 |
Correct |
35 ms |
3952 KB |
Output is correct |
19 |
Correct |
29 ms |
4076 KB |
Output is correct |
20 |
Correct |
39 ms |
4332 KB |
Output is correct |
21 |
Correct |
44 ms |
4364 KB |
Output is correct |
22 |
Correct |
39 ms |
4204 KB |
Output is correct |
23 |
Correct |
42 ms |
4460 KB |
Output is correct |
24 |
Correct |
43 ms |
4564 KB |
Output is correct |
25 |
Correct |
43 ms |
4588 KB |
Output is correct |
26 |
Correct |
44 ms |
4588 KB |
Output is correct |
27 |
Correct |
44 ms |
4332 KB |
Output is correct |
28 |
Correct |
42 ms |
4332 KB |
Output is correct |
29 |
Correct |
41 ms |
4332 KB |
Output is correct |
30 |
Correct |
42 ms |
4460 KB |
Output is correct |
31 |
Correct |
43 ms |
4332 KB |
Output is correct |
32 |
Correct |
43 ms |
4460 KB |
Output is correct |
33 |
Correct |
42 ms |
4460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
4076 KB |
Output is correct |
2 |
Correct |
35 ms |
3952 KB |
Output is correct |
3 |
Correct |
29 ms |
4076 KB |
Output is correct |
4 |
Correct |
39 ms |
4332 KB |
Output is correct |
5 |
Correct |
44 ms |
4364 KB |
Output is correct |
6 |
Correct |
39 ms |
4204 KB |
Output is correct |
7 |
Correct |
42 ms |
4460 KB |
Output is correct |
8 |
Correct |
43 ms |
4564 KB |
Output is correct |
9 |
Correct |
43 ms |
4588 KB |
Output is correct |
10 |
Correct |
44 ms |
4588 KB |
Output is correct |
11 |
Correct |
44 ms |
4332 KB |
Output is correct |
12 |
Correct |
42 ms |
4332 KB |
Output is correct |
13 |
Correct |
41 ms |
4332 KB |
Output is correct |
14 |
Correct |
42 ms |
4460 KB |
Output is correct |
15 |
Correct |
43 ms |
4332 KB |
Output is correct |
16 |
Correct |
43 ms |
4460 KB |
Output is correct |
17 |
Correct |
42 ms |
4460 KB |
Output is correct |
18 |
Correct |
30 ms |
4204 KB |
Output is correct |
19 |
Correct |
29 ms |
4076 KB |
Output is correct |
20 |
Correct |
29 ms |
4076 KB |
Output is correct |
21 |
Correct |
29 ms |
4076 KB |
Output is correct |
22 |
Correct |
29 ms |
4076 KB |
Output is correct |
23 |
Correct |
29 ms |
4076 KB |
Output is correct |
24 |
Correct |
32 ms |
4076 KB |
Output is correct |
25 |
Correct |
33 ms |
4076 KB |
Output is correct |
26 |
Correct |
30 ms |
4076 KB |
Output is correct |
27 |
Correct |
30 ms |
4076 KB |
Output is correct |
28 |
Correct |
29 ms |
4076 KB |
Output is correct |
29 |
Correct |
30 ms |
4076 KB |
Output is correct |
30 |
Correct |
29 ms |
4076 KB |
Output is correct |
31 |
Correct |
29 ms |
4076 KB |
Output is correct |
32 |
Correct |
29 ms |
4096 KB |
Output is correct |
33 |
Correct |
30 ms |
4076 KB |
Output is correct |
34 |
Correct |
41 ms |
4204 KB |
Output is correct |
35 |
Correct |
48 ms |
4204 KB |
Output is correct |
36 |
Correct |
39 ms |
4204 KB |
Output is correct |
37 |
Correct |
43 ms |
4460 KB |
Output is correct |
38 |
Correct |
42 ms |
4332 KB |
Output is correct |
39 |
Correct |
42 ms |
4332 KB |
Output is correct |
40 |
Correct |
42 ms |
4332 KB |
Output is correct |
41 |
Correct |
38 ms |
4332 KB |
Output is correct |
42 |
Correct |
42 ms |
4460 KB |
Output is correct |
43 |
Correct |
42 ms |
4460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
4204 KB |
Output is correct |
2 |
Correct |
48 ms |
4204 KB |
Output is correct |
3 |
Correct |
39 ms |
4204 KB |
Output is correct |
4 |
Correct |
43 ms |
4460 KB |
Output is correct |
5 |
Correct |
42 ms |
4332 KB |
Output is correct |
6 |
Correct |
42 ms |
4332 KB |
Output is correct |
7 |
Correct |
42 ms |
4332 KB |
Output is correct |
8 |
Correct |
38 ms |
4332 KB |
Output is correct |
9 |
Correct |
42 ms |
4460 KB |
Output is correct |
10 |
Correct |
42 ms |
4460 KB |
Output is correct |
11 |
Correct |
30 ms |
4076 KB |
Output is correct |
12 |
Correct |
35 ms |
3952 KB |
Output is correct |
13 |
Correct |
29 ms |
4076 KB |
Output is correct |
14 |
Correct |
39 ms |
4332 KB |
Output is correct |
15 |
Correct |
44 ms |
4364 KB |
Output is correct |
16 |
Correct |
39 ms |
4204 KB |
Output is correct |
17 |
Correct |
42 ms |
4460 KB |
Output is correct |
18 |
Correct |
43 ms |
4564 KB |
Output is correct |
19 |
Correct |
43 ms |
4588 KB |
Output is correct |
20 |
Correct |
44 ms |
4588 KB |
Output is correct |
21 |
Correct |
44 ms |
4332 KB |
Output is correct |
22 |
Correct |
42 ms |
4332 KB |
Output is correct |
23 |
Correct |
41 ms |
4332 KB |
Output is correct |
24 |
Correct |
42 ms |
4460 KB |
Output is correct |
25 |
Correct |
43 ms |
4332 KB |
Output is correct |
26 |
Correct |
43 ms |
4460 KB |
Output is correct |
27 |
Correct |
42 ms |
4460 KB |
Output is correct |
28 |
Correct |
30 ms |
4204 KB |
Output is correct |
29 |
Correct |
29 ms |
4076 KB |
Output is correct |
30 |
Correct |
29 ms |
4076 KB |
Output is correct |
31 |
Correct |
29 ms |
4076 KB |
Output is correct |
32 |
Correct |
29 ms |
4076 KB |
Output is correct |
33 |
Correct |
29 ms |
4076 KB |
Output is correct |
34 |
Correct |
32 ms |
4076 KB |
Output is correct |
35 |
Correct |
33 ms |
4076 KB |
Output is correct |
36 |
Correct |
30 ms |
4076 KB |
Output is correct |
37 |
Correct |
30 ms |
4076 KB |
Output is correct |
38 |
Correct |
29 ms |
4076 KB |
Output is correct |
39 |
Correct |
30 ms |
4076 KB |
Output is correct |
40 |
Correct |
29 ms |
4076 KB |
Output is correct |
41 |
Correct |
29 ms |
4076 KB |
Output is correct |
42 |
Correct |
29 ms |
4096 KB |
Output is correct |
43 |
Correct |
30 ms |
4076 KB |
Output is correct |
44 |
Correct |
540 ms |
15284 KB |
Output is correct |
45 |
Correct |
392 ms |
12260 KB |
Output is correct |
46 |
Correct |
459 ms |
16172 KB |
Output is correct |
47 |
Correct |
468 ms |
16172 KB |
Output is correct |
48 |
Correct |
554 ms |
21216 KB |
Output is correct |
49 |
Correct |
544 ms |
21560 KB |
Output is correct |
50 |
Correct |
499 ms |
13996 KB |
Output is correct |
51 |
Correct |
547 ms |
15276 KB |
Output is correct |
52 |
Correct |
533 ms |
14384 KB |
Output is correct |
53 |
Correct |
420 ms |
12088 KB |
Output is correct |
54 |
Correct |
556 ms |
21168 KB |
Output is correct |
55 |
Correct |
558 ms |
21072 KB |
Output is correct |