CF589G Hiring
Description
The head of human resources department decided to hire a new employee. He created a test exercise for candidates which should be accomplished in at most $ m $ working days. Each candidate has to pass this test exercise. During the $ j $ -th day a candidate is allowed to be in the office for at most $ t_{j} $ units of time.
Overall, $ n $ candidates decided to apply for the job and sent out their resumes. Based on data received the head has defined two parameters describing every candidate: $ d_{i} $ and $ r_{i} $ . The parameter $ d_{i} $ is the time to get prepared for work which the $ i $ -th candidate spends each morning. This time doesn't depend on day. The parameter $ r_{i} $ is the total working time needed for the $ i $ -th candidate to accomplish the whole test exercise.
Thus the time spent in the office in the $ j $ -th day consists of $ d_{i} $ units of time to get prepared and some units of time to proceed with the exercise. A candidate can skip entire working day and do not come to the office. Obviously in this case he doesn't spend $ d_{i} $ units of time to prepare.
To complete the exercise a candidate should spend exactly $ r_{i} $ units of time working on the exercise (time to prepare is not counted here).
Find out for each candidate what is the earliest possible day when he can fully accomplish the test exercise. It is allowed to skip working days, but if candidate works during a day then he must spend $ d_{i} $ units of time to prepare for work before he starts progressing on the exercise.
Input Format
The first line contains two integer numbers $ n,m $ $ (1
Output Format
Output a sequence of $ n $ integer numbers $ b_{1},b_{2},...,b_{n} $ , where $ b_{i} $ is the earliest day when the $ i $ -th candidate can finish the test exercise.
In case the $ i $ -th candidate cannot finish the test exercise in $ m $ days output $ b_{i}=0 $ .
Days in this problem are numbered from 1 to $ m $ in the order they are given in the input.