Coke Drinking Contest
Time limit1sMemory limit512 MB
Given N entrants who each drink A mL per second with fixed drinking and resting periods, find when the first entrant finishes K mL.
- Level
Easy3 of 10
- Topics
- Math, Simulation, Implementation
- Solved
- No attempts yet
Problem
Taeyeong likes coke so much that he cannot get through a single day without it, and the coke made by Jaemin's company is his favorite. Jaemin decided to sponsor him, and with that money Taeyeong is holding the first coke drinking contest in Daejeon.
people enter the contest. Each entrant receives mL of coke and starts drinking the moment the bell rings, and the first person to empty the cup wins. Drinking it all at once hurts because of the carbonation, so every entrant alternates between drinking and resting. Each entrant drinks mL per second, and entrant repeats a cycle of drinking for seconds and then resting for seconds. The winner is decided at the instant some entrant has 0 mL left, and the contest ends there.
Given the information of the entrants, print how many seconds after the start the winner is decided.
Input
The first line contains the natural numbers (), (), and (), separated by spaces. is a multiple of . Each of the next lines contains the natural numbers () and () for entrant .
Output
Print the time at which the winner is decided, as an integer number of seconds counted from the start of the contest.