Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- num_petrol_pumps = int(input())
- gas_tank = 0
- list_of_gas_stations = deque()
- station_num = 0
- for _ in range(num_petrol_pumps):
- info = [int(x) for x in input().split()]
- list_of_gas_stations.append(info)
- while list_of_gas_stations:
- current_pump = list_of_gas_stations.popleft()
- litters = current_pump [0]
- distance = current_pump[1]
- available_fuel = gas_tank + litters
- if available_fuel < distance:
- list_of_gas_stations.append(current_pump)
- station_num += 1
- else:
- litters_left = (available_fuel - distance)
- gas_tank = litters_left
- print(station_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement