Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- pumps_number = int(input())
- fuel = 0
- pumps_que = deque()
- start_position = 0
- for _ in range(pumps_number):
- current_fuel, distance = input().split()
- pumps_que.append((int(current_fuel), int(distance)))
- current_position = 0
- while current_position <= pumps_number - 1:
- is_successful = False
- fuel = 0
- for i in range(pumps_number):
- if pumps_que[i][0] + fuel >= pumps_que[i][1]:
- fuel += pumps_que[i][0]
- fuel -= pumps_que[i][1]
- is_successful = True
- else:
- start_position += 1
- fuel = 0
- is_successful = False
- break
- if not is_successful:
- pumps_que.rotate(-1)
- current_position += 1
- else:
- break
- print(start_position)
Add Comment
Please, Sign In to add comment