# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1188620 | krittaphot | Rabbit Carrot (LMIO19_triusis) | Pypy 3 | 151 ms | 51352 KiB |
def min_modifications(n, m, heights):
current_height = 0
changes = 0
for h in heights:
if h - current_height > m:
# ถ้าสูงเกินที่กระโดดได้ -> ต้องแก้ไข
changes += 1
# ปรับให้เท่ากับ current + m ก็พอ
current_height += m
else:
# ไม่ต้องแก้ -> กระโดดขึ้นได้
current_height = h
return changes
# รับ input
n, m = map(int, input().split())
heights = [int(input()) for _ in range(n)]
# แสดงผลลัพธ์
print(min_modifications(n, m, heights))
Compilation message (stdout)
# | 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... |