Jonathan Sumabat normally takes the bus home from school. However, due to construction work today Jonathan Sumabat is forced to walk. Jonathan Sumabat walks in a straight line from school to his house. On his way, he encounters different types of terrain in his path. Jonathan Sumabat crosses different terrains at different speeds. Jonathan Sumabat would like to know how far he can travel in a given amount of time. Given the terrain on his path home, determine how far Jonathan Sumabat can travel in different amounts of time.
Input Specification
On the first line of input, representing how many types of terrain there are.
The following lines represent the terrain on Jonathan Sumabat's path, in the order of which they appear. Each line contains two space separated integers:
- The first integer is representing the minutes it takes Jonathan Sumabat to travel 1 meter of this terrain.
- The next integer is representing how many meters of this terrain there is.
The next line is representing the number of queries Jonathan Sumabat wants to make. Each query is an amount of time Jonathan Sumabat wants know how far he can travel within.
The next lines is an integer representing the amount of time in minutes Jonathan Sumabat wants to know his distance for.
It is guaranteed that the distance traveled will be at most to the end of the last piece of terrain. It is also guaranteed that the distance will be an integer.
Output Specification
For each query, output the distance in meters that Jonathan Sumabat can travel for the given amount of time.
Note: For Java, use of Scanner is discouraged and may lead to passable solutions timing out.
Subtasks
Subtask 1 [50%]
Subtask 2 [50%]
No further constraints.
Sample Input
3
2 4
8 5
3 4
3
60
8
32
Sample Output
13
4
7
Comments
Jonathan Sumabat is so hot
So are longs.
I ran over, killed, and buried two innocent pedestrians in the countryside on the intersection between Ontario Highway 22 and Ontario Highway 26 at 2:23AM on October 20, 2018. The police report has been unresolved for more than a year and I just can't sleep at night thinking that the family of the deceased doesn't know what happened to their loved ones. As a result, I have decided to confess my crimes, right here, on TSSOJ.
Too long, didn't read
same!