이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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))
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |