time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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

Note

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.

【题目链接】:http://codeforces.com/contest/586/problem/C

【题解】



模拟题;

每次让一个小孩进杨永信的电击室;那个小孩的哭声造成的影响可以一直往后移;然后途中如果有小孩子被吓跑了;则可以把这个小孩的吓跑的哭声也累加到那个被电的小孩的哭声里面;注意那个被电的小孩的哭声的作用范围是有限的;所以不能一直减;减了v[i]次后就不减了;而其他被吓跑的小孩的哭声则不用减;

开long long吧;养成好习惯.



【完整代码】

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long using namespace std; const int MAXN = 4000+100;
const int dx[5] = {0,1,-1,0,0};
const int dy[5] = {0,0,0,-1,1};
const double pi = acos(-1.0); int n;
LL v[MAXN],d[MAXN],p[MAXN];
vector <int> ans; void rel(LL &r)
{
r = 0;
char t = getchar();
while (!isdigit(t) && t!='-') t = getchar();
LL sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
} void rei(int &r)
{
r = 0;
char t = getchar();
while (!isdigit(t)&&t!='-') t = getchar();
int sign = 1;
if (t == '-')sign = -1;
while (!isdigit(t)) t = getchar();
while (isdigit(t)) r = r * 10 + t - '0', t = getchar();
r = r*sign;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
for (int i = 1;i <= n;i++)
rel(v[i]),rel(d[i]),rel(p[i]);
int now = 1;
while (now <= n)
{
if (p[now] >= 0)
ans.push_back(now);
else
{
now++;
continue;
}
LL sub = v[now];
for (int i = now+1;i<= n;i++)
if (p[i] >= 0)
{
p[i]-=sub;
if (p[i] < 0)
sub+=d[i];
if (v[now]>0)
{
sub--;
v[now]--;
}
if (sub == 0)
break;
}
now++;
}
int len = ans.size();
printf("%d\n",len);
for (int i = 0;i <= len-2;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[len-1]);
return 0;
}

【16.23%】【codeforces 586C】Gennady the Dentist的更多相关文章

  1. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  2. 【23.39%】【codeforces 558C】Amr and Chemistry

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【20.23%】【codeforces 740A】Alyona and copybooks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【23.33%】【codeforces 557B】Pasha and Tea

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【30.23%】【codeforces 552C】Vanya and Scales

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【23.26%】【codeforces 747D】Winter Is Coming

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【77.78%】【codeforces 625C】K-special Tables

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  8. 【codeforces 602D】Lipshitz Sequence

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【codeforces 755E】PolandBall and White-Red graph

    [题目链接]:http://codeforces.com/contest/755/problem/E [题意] 给你n个节点; 让你在这些点之间接若干条边;构成原图(要求n个节点都联通) 然后分别求出 ...

随机推荐

  1. 【Codeforces Round #433 (Div. 1) B】Jury Meeting

    [链接]h在这里写链接 [题意] 有n个人,它们都要在某一时刻开始,全都到达0位置,然后维持最少k个时间单位,然后再全都回到原来的位置; 第i个人初始的位置是i. 且一共有m班航班. 每一班航班,要么 ...

  2. 洛谷——P3128 [USACO15DEC]最大流Max Flow

    https://www.luogu.org/problem/show?pid=3128 题目描述 Farmer John has installed a new system of  pipes to ...

  3. hdu2049(组合数学)

    题意:每位新娘打扮得差点儿一模一样,并盖上大大的红盖头随机坐成一排;然后,让各位新郎寻找自己的新娘.每人仅仅准找一个,而且不同意多人找一个.最后,揭开盖头,如果找错了对象就要当众跪搓衣板...如果一共 ...

  4. 去哪网实习总结:用到的easyui组件总结(JavaWeb)

    本来是以做数据挖掘的目的进去哪网的,结构却成了系统开发... 只是还是比較认真的做了三个月,老师非常认同我的工作态度和成果.. . 实习立即就要结束了,总结一下几点之前没有注意过的变成习惯和问题,分享 ...

  5. OC的DES加密,使与java的Cipher类用DES/CBC/PKCS5Padding方式的加密结果同样

    问题说明: 近期用到DES加密,而且要与java的Cipher类加密的结果保持一致.没研究过java的Cliper,但工作中Cipher依据DES/CBC/PKCS5Padding加密方式生成了一个字 ...

  6. vue 用 :style动态修改带中划线的样式属性

    今天在项目中遇到要用:style动态设置margin-top值,直接写发现报错.后来改成驼峰就成功了,记录一下 错误示范: <div class="testLeft ulData&qu ...

  7. Linux_Shell初级编程入门

    从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...

  8. BI并不是万能,中层业务管理报表要另辟蹊径

           BI是商业智能的缩写,是能够帮助企业做出明智的业务经营决策的工具.其数据来源于各个业务系统.如ERP.CRM.SCM.进销存.HER.OA等.        BI系统不同于传统的管理信息 ...

  9. UVA 11728 - Alternate Task (数论)

    Uva 11728 - Alternate Task 题目链接 题意:给定一个因子和.求出相应是哪个数字 思路:数字不可能大于因子和,对于每一个数字去算出因子和,然后记录下来就可以 代码: #incl ...

  10. swift项目第三天:手写代码搭建主框架

    一:先配置环境:自定义Log输出(DEBUG 和 release模式),并屏蔽后台多余的打印信息 1:屏蔽后台多余的打印信息:如果写了OS_ACTIVITY_MODE = disable 还是不行.把 ...