CF585A.Gennady the Dentist
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office.
All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to n in the order they go in the line. Every child is associated with the value of his cofidence p__i. The children take turns one after another to come into the office; each time the child that is the first in the line goes to the doctor.
While Gennady treats the teeth of the i-th child, the child is crying with the volume of v__i. At that the confidence of the first child in the line is reduced by the amount of v__i, the second one — by value v__i - 1, and so on. The children in the queue after the v__i-th child almost do not hear the crying, so their confidence remains unchanged.
If at any point in time the confidence of the j-th child is less than zero, he begins to cry with the volume of d__j and leaves the line, running towards the exit, without going to the doctor's office. At this the confidence of all the children after the j-th one in the line is reduced by the amount of d__j.
All these events occur immediately one after the other in some order. Some cries may lead to other cries, causing a chain reaction. Once in the hallway it is quiet, the child, who is first in the line, goes into the doctor's office.
Help Gennady the Dentist to determine the numbers of kids, whose teeth he will cure. Print their numbers in the chronological order.
根纳季是贝尔兰最出色的儿童牙医之一。今天有 n 个孩子预约了他,他们在他的诊所门前排起了队。
所有孩子都喜欢在牙科诊所前台大声哭闹。我们按排队顺序,用从 1 到 n 的整数对孩子们进行编号。每个孩子都有一个与其关联的“信心值” pi。孩子们依次进入诊室;每次都是队伍最前面的孩子前往医生处就诊。
当根纳季为第 i 个孩子治疗牙齿时,该孩子会以音量 vi 哭闹。此时,队列中排在第一位的孩子的信心值减少 vi,排在第二位的孩子的信心值减少 vi−1,依此类推。排在第 vi 位之后的孩子几乎听不到哭声,因此他们的信心值保持不变。
如果在任意时刻,第 j 个孩子的信心值小于零,他便会以音量 dj 开始哭闹,并立即离开队伍、奔向出口,不再前往医生诊室。此时,队列中排在第 j 个孩子之后的所有孩子的信心值均减少 dj。
所有这些事件立即按某种顺序接连发生。某些哭闹可能引发其他哭闹,从而导致连锁反应。当走廊恢复安静后,当前排在队伍最前面的孩子便进入医生诊室。
请帮助牙医根纳季确定他最终将为哪些孩子治疗牙齿。按治疗发生的时间顺序输出这些孩子的编号。
输入格式
The first line of the input contains a positive integer n (1 ≤ n ≤ 4000) — the number of kids in the line.
Next n lines contain three integers each v__i, d__i, p__i (1 ≤ v__i, d__i, p__i ≤ 106) — the volume of the cry in the doctor's office, the volume of the cry in the hall and the confidence of the i-th child.
输入的第一行包含一个正整数 n(1 ≤ n ≤ 4000)—— 表示队列中孩子的数量。
接下来的 n 行,每行包含三个整数 vi、di、pi(1 ≤ vi, di, pi ≤ 106)—— 分别表示第 i 个孩子在医生办公室中的哭声音量、在走廊中的哭声音量以及该孩子的自信心。
输出格式
In the first line print number k — the number of children whose teeth Gennady will cure.
In the second line print k integers — the numbers of the children who will make it to the end of the line in the increasing order.
第一行输出一个整数 k —— 表示根纳季将治疗牙齿的孩子人数。
第二行输出 k 个整数 —— 表示最终能到达队列末尾的孩子编号,按升序排列。
输入输出样例
输入#1
5 4 2 2 4 1 2 5 2 4 3 3 5 5 1 2
输出#1
2 1 3
输入#2
5 4 5 1 5 3 9 4 1 2 2 1 8 4 1 9
输出#2
4 1 2 4 5
说明/提示
In the first example, Gennady first treats the teeth of the first child who will cry with volume 4. The confidences of the remaining children will get equal to - 2, 1, 3, 1, respectively. Thus, the second child also cries at the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 0, 2, 0. Then the third child will go to the office, and cry with volume 5. The other children won't bear this, and with a loud cry they will run to the exit.
In the second sample, first the first child goes into the office, he will cry with volume 4. The confidence of the remaining children will be equal to 5, - 1, 6, 8. Thus, the third child will cry with the volume of 1 and run to the exit. The confidence of the remaining children will be equal to 5, 5, 7. After that, the second child goes to the office and cry with the volume of 5. The confidences of the remaining children will be equal to 0, 3. Then the fourth child will go into the office and cry with the volume of 2. Because of this the confidence of the fifth child will be 1, and he will go into the office last.
在第一个样例中,根纳季首先为第一个孩子治疗牙齿,该孩子将发出音量为 4 的哭声。其余孩子的信心值将分别变为 −2,1,3,1。因此,第二个孩子也会以音量 1 哭喊并跑向出口。剩余孩子的信心值将变为 0,2,0。接着,第三个孩子进入诊室,并发出音量为 5 的哭声。其余孩子无法忍受,便大声哭喊着奔向出口。
在第二个样例中,首先第一个孩子进入诊室,他将发出音量为 4 的哭声。其余孩子的信心值将变为 5,−1,6,8。因此,第三个孩子将以音量 1 哭喊并跑向出口。剩余孩子的信心值将变为 5,5,7。随后,第二个孩子进入诊室并发出音量为 5 的哭声。其余孩子的信心值将变为 0,3。接着,第四个孩子进入诊室并发出音量为 2 的哭声。受此影响,第五个孩子的信心值变为 1,因此他最后进入诊室。
输入解题思路,AI测评打分。不知道怎么写?