Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Truck Tour"""
- # judge
- # https://judge.softuni.org/Contests/Practice/Index/1831#4
- from collections import deque
- gas_station = int(input())
- liters, kilometers = deque(), deque()
- current_gas_station = 0
- for i in range(gas_station):
- liter, kilometer = map(int, input().split())
- liters.append(liter)
- kilometers.append(kilometer)
- if sum(kilometers) <= sum(liters):
- while liters:
- current_liter = liters.popleft()
- current_kilometer = kilometers.popleft()
- if current_liter < current_kilometer:
- current_gas_station += 1
- liters.append(current_liter)
- kilometers.append(current_kilometer)
- else:
- remaining_liters = current_liter - current_kilometer
- if kilometers:
- liters[0] += remaining_liters
- else:
- break
- print(current_gas_station)
- """
- input:
- 5
- 22 5
- 14 10
- 52 7
- 21 12
- 36 9
- output:
- 0
- """
Add Comment
Please, Sign In to add comment