NOBLE-_-MAN

4 monke

Oct 27th, 2021
624
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lian = int(input())
  2. d = int(input())
  3. jumps = []
  4. for i in range(lian):
  5.     jumps.append(int(input()))
  6. i = 0
  7. while i < (lian - 1):
  8.     if jumps[i] // d == 0:
  9.         break
  10.     max_jump = jumps[i] // d
  11.     for j in range(i + 1, i + jumps[i] // d + 1):
  12.         if j >= lian - 1:
  13.             break
  14.         if jumps[j] // d + j - i > max_jump:
  15.             max_jump = jumps[j] // d + j - i
  16.     i += max_jump
  17.     if i >= lian - 1:
  18.         i = lian - 1
  19.         break
  20. print(i + 1)
RAW Paste Data