@TOC寒假训练赛小结
【武汉加油】寒假训练赛20200130|抗击病毒最好的办法就是敲代码缓解焦虑
早上起床,打开了好久没有打开的书,看了半本《平凡的世界》,那个年代好多事情我都没有经历,二刷还是没能进入人物的生活。
最近武汉疫情严重,家中不大的小城也受到了影响,出不去拍照,之前拍的老图看久了眼睛也有点花,想想带回来了不少课外书,寒假训练赛前面也一直没有打,只是不着边际得看了一些之前没看懂的算法。
趁热打铁,今天训练赛灵感有点点爆炸,A了四个,一发。但是面对不会的还是一点头绪都没有,所以在还有半小时的时候放弃,那么闲着也是闲着,家里的饭还没做好,就写下了这个总结,也是第一次写博客,我还是太菜了,哭了。
A Gennady the Dentist
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 pi. 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 vi. At that the confidence of the first child in the line is reduced by the amount of vi, the second one — by value vi - 1, and so on. The children in the queue after the vi-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 dj 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 dj.
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.
INPUT
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 vi, di, pi (1 ≤ vi, di, pi ≤ 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.
OUTPUT
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.
Examples
Input
5
4 2 2
4 1 2
5 2 4
3 3 5
5 1 2
Output
2
1 3
Input
5
4 5 1
5 3 9
4 1 2
2 1 8
4 1 9
Output
4
1 2 4 5
题意
n个小孩,有三个值v,d,p。
现取走队列中第一个小孩。小孩释放扩散性伤害,使得在他后面的第一个小孩受到伤害v,第二个v-1,一直到伤害为0为止。
如果有一个小孩中途收到扩散性伤害累加值大于p,小孩离去,并对后面所有的小孩产生无差别伤害d。
求哪些小孩被取走,并输出他们的下标。
刚开始没太理清楚题意,之后就直接跳了过去,看了一眼后面的题目又跳了回来。哈哈哈哈。
我就开始硬着头皮模拟,模拟完试了一下样例,样例过了,但是好像影影约约发现有坑,如果不加判断一直减d,会使得p值作为一个负数int溢出变成正的,造成错误。我就加了一个特判负数不必再减d.
最后上一发AC代码
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define LL long long
const int maxn = 4005;
struct child{
LL v,d,p;
}child[maxn];
int n,count1,ans[maxn];
int main(){
scanf("%d",&n);
for(int i =1;i<=n;i++){
scanf("%ld%ld%ld",&child[i].v,&child[i].d,&child[i].p);
}
for(int i = 1;i<=n;i++){
if(child[i].p<0) continue;