题目是这个:
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 tj units of time.
人力资源部的负责人决定雇用一名新员工。他为候选人们设置了一个测试练习,该练习最多可以在m 个工作日内完成。每个考生都必须通过这个测试练习。在第j天,候选人最多可以在办公室待tj个单位的时间。
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: di and ri. The parameter di 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 ri is the total working time needed for the i-th candidate to accomplish the whole test exercise.
总而言之,n 名候选人决定应聘这份工作并投递了他们的简历。根据收到的数据,负责人定义了两个参数来描述每个候选者:di 和 ri 。参数 di 是第i个候选人每天早上为工作做准备的时间。这个时间不取决于工作日。参数ri 是第i个候选者完成整个测试练习所需的总工作时间。
Thus the time spent in the office in the j-th day consists of di 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 di units of time to prepare.
因此,第j天在办公室度过的时间包括 di 个单位的准备时间和进行测试练习的时间。候选人可以跳过整个工作日,不来办公室。显然,在这种情况下,他不用花 di 个单位的时间来准备。
To complete the exercise a candidate should spend exactly ri units of time working on the exercise (time to prepare is not counted here).
为了完成练习,候选人应该花整整 r 个单位的时间在练习上(这里不计算准备时间)。
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 di units of time to prepare for work before he starts progressing on the exercise.
为每位考生找出他可以完全完成测试练习的最早一天。可以跳过工作日,但如果候选人在某一天选择工作,那么他必须花 d 个单位的时间来准备工作,然后才能开始练习。
Input 输入
The first line contains two integer numbers n,m (1≤n,m≤2·105)−the number of candidates and the maximum number of working days to do the test exercise.
第一行包含两个整数 n,m(1≤n,m≤2·10 5 )分别为考生人数和进行测试练习的最大工作日数。
The second line contains m integer numbers t1,t2,...,tm (1≤tj≤106)− the durations of working days in time units.
第二行包含 m 个整数t1,t2,...,tm (1≤tj≤106),为以时间单位表示的工作日可工作时间。
The following n lines contain two integers each: di,ri (0≤di≤106,1≤ri≤106)− how much time in the beginning of a day is required for i-th candidate before he starts his work on the test exercise and how much time it is needed for him to accomplish this task.
以下 n 行每行包含两个整数:di,ri (0≤di≤106,1≤ri≤106),为第i个考生的准备时间,以及他需要多少时间才能完成这项任务。
Output 输出
Output a sequence of n integer numbers b1,b2,...,bn, where bi is the earliest day when the i-th candidate can finish the test exercise.
输出 n 个整数 b1,b2,...,bn, 的序列,其中bi 是第i个候选者可以完成测试练习的最早一天。
In case the i-th candidate cannot finish the test exercise in m days output bi=0.
如果第i个考生无法在 m 天内完成测试练习,则输出 bi =0。
Days in this problem are numbered from 1 to m in the order they are given in the input.
此问题中的天数按输入中给出的顺序从 1 到 m 编号。
测试用例:
Input
3 3
4 2 5
1 3
2 5
3 4
Output
1 3 0
我不明白为什么输出的第二个是3?对于第二位应聘者来说,要找出最早的一天,只要第一天和第三天去就行了吧?为什么要去三天?