C. Gennady the Dentist

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/586/problem/C

Description

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.

i​​,C​i​​,即此题的初始分值、每分钟减少的分值、dxy做这道题需要花费的时间。

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.

Sample Input

5
4 2 2
4 1 2
5 2 4
3 3 5
5 1 2

Sample Output

2
1 3

HINT

题意

一堆小孩要去看牙医,小孩进入牙医之后,就会发出叫声,使得接下来的v[i]个孩子的信心分别下降v[i],v[i]-1......1这么多

如果小孩被吓跑了,他们又会叫,使得接下来的孩子发出d[i]的叫声

然后问你一共有多少人能够看病,并且是哪些人

题解:

数据范围只有4000,那就n^2暴力就好了

有两个坑点:

1.爆int

2.得v[i]减完之后,大家再一起叫d[i]的,不是边v[i]边d[i]

代码:

#include<stdio.h>
#include<iostream>
#include<math.h>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std; long long v[],d[],p[];
long long ans[];
long long flag[];
int n;
int main()
{
memset(flag,,sizeof(flag));
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%lld%lld%lld",&v[i],&d[i],&p[i]);
int tot = ;
for(int i=;i<=n;i++)
{
if(p[i]<)continue;
ans[tot++]=i;
long long sum=;
long long time = v[i];
for(int j=i+;j<=n;j++)
{
flag[j]=;
if(p[j]>=)
{
flag[j]=;
if(time>)
p[j]-=time;
time--;
}
}
for(int j=i+;j<=n;j++)
{
if(p[j]>=)
p[j]-=sum;
if(p[j]<&&flag[j])
sum+=d[j];
}
}
printf("%d\n",tot);
for(int i=;i<tot;i++)
printf("%lld ",ans[i]);
printf("\n");
}

Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力的更多相关文章

  1. Codeforces Round #325 (Div. 2) A. Alena's Schedule 暴力枚举 字符串

    A. Alena's Schedule time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索

    Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx ...

  3. Codeforces Round #325 (Div. 2)

    水 A - Alena's Schedule /************************************************ * Author :Running_Time * Cr ...

  4. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  5. Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS

    D. Phillip and Trains Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/ ...

  6. Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题

    A. Alena's Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/pr ...

  7. Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和

    B. Laurenty and Shop Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/p ...

  8. Codeforces Round #325 (Div. 2) Phillip and Trains dp

    原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...

  9. Codeforces Round #325 (Div. 2) Laurenty and Shop 模拟

    原题链接:http://codeforces.com/contest/586/problem/B 题意: 大概就是给你一个两行的路,让你寻找一个来回的最短路,并且不能走重复的路. 题解: 就枚举上下选 ...

随机推荐

  1. [ffmpeg 扩展第三方库编译系列] 关于libvpx mingw32编译问题

    在编译libvpx的时候遇到挺多的问题, 1.[STRIP] libvpx.a < libvpx_g.a strip: Bad file number   这个错误也是比较难搞的,一开始以为只是 ...

  2. NET SCADA软件简介

    Scada是一款采用.Net WPF开发的免费组态软件,功能强大,支持服务器客户端方式运行.支持浏览器运行,软件非常小巧,免安装,支持Modbus和OPC通讯协议, 开放构架,支持C#.Net脚本,J ...

  3. C#中父窗口和子窗口之间实现控件互操作

    很多人都苦恼于如何在子窗体中操作主窗体上的控件,或者在主窗体中操作子窗体上的控件.相比较而言,后面稍微简单一些,只要在主窗体中创建子窗体的时候,保留所创建子窗体对象即可. 下面重点介绍前一种,目前常见 ...

  4. js 动态计算折扣后总价格

    <script type="text/javascript"> <!---计算折扣后的总价格---> function outtotalprice(i) { ...

  5. 银行爱“IOE”爱得有多深

    本文由阿尔法工场欧阳长征推荐 导读:如果银行是一家海鲜酒楼,把IBM换掉相当于大搞一次装修,把Oracle换掉相当于把厨子和菜谱全部换掉,把EMC换掉相当于把放食材工具的储物间换个地方.难度在于,这海 ...

  6. mysql中php生成唯一ID

    <?php //uniqid官方手册 function create_guid($namespace = '') { static $guid = ''; $uid = uniqid(" ...

  7. android.content.res.Resources$NotFoundException: String resource ID #0x1

    之前忘了记录这个错误,今天又遇到了.唉,人不能纵容自己犯懒,遂记录之. 错误:android.content.res.Resources$NotFoundException: String resou ...

  8. GIS:揭开你神秘的面纱

    转自:http://www.cnblogs.com/gisangela/archive/2013/02/20/2918884.html#!comments GIS从出现到为人所知,只不过经历了短短的几 ...

  9. 《深入Java虚拟机学习笔记》- 第6章 class文件

    一.class文件内容 Java class文件是对Java程序二进制文件格式的精确定义.每一个Java class文件都对一个Java类或者Java接口作出了全面描述.一个class文件只 能包含一 ...

  10. CCR

    不用任何与创建线程.资源互斥有关系的API写多线程程序 这次的例子,是一个很简单的控制台,她将面对瞬间提交的百万的数据,而面不改色(CPU.内存非常平稳),队列中始终只保存最新的数据,每次只处理cpu ...