Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- gas_station = int(input())
- petrol_pumps = deque()
- total_petrol = 0
- distance_to_next = 0
- start_index = 0
- for i in range(gas_station):
- petrol, distance = map(int, input().split())
- petrol_pumps.append((petrol, distance))
- total_petrol += petrol
- total_petrol -= distance
- distance_to_next += distance
- if total_petrol < 0:
- start_index = i + 1
- total_petrol = 0
- distance_to_next = 0
- print(start_index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement