Crazy Transport Taxes
InterviewTime limit2sMemory limit1024 MB
Given a step-function rate table and a list of car powers, print each car's tax, which is the matching band's rate times the power.
- Level
Easy3 of 10
- Topics
- Binary search, Array
- Solved
- No attempts yet
Problem
Arthur Fleck was once an ordinary person with ordinary needs. One of them was buying a car.
As is well known, owning a car means paying a transport tax, and Gotham is no exception. To find the transport tax on a car, you need its engine power in horsepower. Then look up the tax rate for that power in the rate table, and multiply the rate by the power.
An example rate table:
The rate in row applies to power values strictly greater than the power in that row and less than or equal to the power in the next row (if there is one). If the power is strictly greater than the maximum power in the table, the maximum rate applies.
While choosing a car, Arthur looked at many options and wants the transport tax for each one. Help him.
Input
The first line contains an integer , the number of rows in the rate table ().
Each of the next lines contains a pair of integers , : the power and the rate for row (). It is guaranteed that , and for every , and .
The next line contains an integer , the number of cars Arthur asks about ().
Each of the next lines contains an integer , the power of the -th car ().
Output
For each car, print its transport tax on a separate line.