Advertisement
NOBLE-_-MAN

Untitled

Nov 7th, 2021
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. from math import ceil
  2.  
  3. n, d, t = list(map(int, input().split()))
  4. mas = [[int(j) for j in input().split()] for i in range(n)]
  5. counter = 1
  6. pos = 0
  7. for i in range(n):
  8.     if mas[i][0] - pos > d:
  9.         if (mas[i][0] - pos) % d == 0:
  10.             counter += (mas[i][0] - pos) // d
  11.             pos = mas[i][0]
  12.  
  13.         else:
  14.             counter += (mas[i][0] - pos) // d
  15.             pos += (mas[i][0] - pos) // d * d
  16.  
  17.         if mas[i][1] - pos > d:
  18.             pos = mas[i][0] + d
  19.             counter += 2
  20.         else:
  21.             pos += d
  22.             counter += 1
  23.     else:
  24.         if mas[i][1] - pos > d:
  25.             pos = mas[i][0] + d
  26.             counter += 2
  27.         else:
  28.             pos += d
  29.             counter += 1
  30. if pos < t:
  31.     counter += ceil((t - pos) / d)
  32. print(counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement