제출 #1188624

#제출 시각아이디문제언어결과실행 시간메모리
1188624krittaphotRabbit Carrot (LMIO19_triusis)Pypy 3
0 / 100
152 ms51360 KiB
def min_modifications(n, m, heights): current_height = 0 # เริ่มจากพื้น changes = 0 # นับจำนวนครั้งที่ต้องแก้ไขเสา for h in heights: if h - current_height > m: # กระโดดขึ้นไม่ถึง -> ต้องปรับเสานี้ changes += 1 # ปรับเสานี้ลงให้เท่ากับระดับที่กระโดดได้ current_height = current_height + m else: # กระโดดถึง (ขึ้นไม่เกิน M หรือกระโดดลงได้) current_height = h return changes # ----------- รับ Input จากผู้ใช้ ------------ # ตัวอย่าง input: # 3 300 # 700 # 1000 # 1300 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 32%)

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