Walk in the Park
InterviewTime limit4sMemory limit1024 MB
Given vases with water a_i and drain rates b_i, print the total water left at each integer time from 0 to t.
- Level
Medium4 of 10
- Topics
- Sorting, Prefix sum, Implementation
- Solved
- No attempts yet
Statement
The last week was rainy. Mr. Bean stayed at home for days, and on this sunny day he went for a walk in the central park. Walking along an alley, he saw a bright sign that read "2015: Year of Light!" The sign lifted his mood, and full of inspiration he set off for his destination to do good deeds.
At the park he found a sculpture made of a set of vases of different sizes. The -th vase has size , so over the week it collected units of water. Mr. Bean decided there should be no water in the vases, and as an honest man he set out to fix the situation. He made one hole in each vase. The hole in the -th vase has diameter , so units of water flow out of it per second. The holes were all made at the same moment. Mr. Bean wants to know the total amount of water left in all vases at each moment after the holes were made. Help him answer all of his questions.
Input
The first line contains two integers and (, ), the number of vases and the time during which Mr. Bean is interested in the water in the vases.
Each of the next lines contains two integers and (, ), describing the -th vase.
Output
Print integers. The first line contains the total amount of water at the initial moment. Each following line contains the total amount of water at the next moment.