제출 #1188620

#제출 시각아이디문제언어결과실행 시간메모리
1188620krittaphotRabbit Carrot (LMIO19_triusis)Pypy 3
0 / 100
151 ms51352 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))

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'triusis.py'...

=======
  adding: __main__.pyc (deflated 33%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...