CodeForces#325 C. Gennady the Dentist

点击就送屠龙宝刀

C. Gennady the Dentist

time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard 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.
Sample test(s)
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个熊孩子去看医生,每个人都有一个pi(信心值)、一个vi(声音影响度)、一个di(影响值)。当一个熊孩子接受治疗时,会发出vi的影响,影响后面vi个单位,分别为vi-1,vi-2,vi-3……0.当某个人的信心值pi小于0时,他就吓尿了于是就跑掉了,同时对后面所有人造成di的影响。(注:造成x的影响意思为pi-x)。你的任务就是统计有多少个熊孩子看了医生,并且按照顺序输出他们的编号。

模拟大法好233333毕竟只有4000的范围

#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;
const int maxn = 5500;
int v[maxn],p[maxn],d[maxn];


int main()
{
    int n,ans=0;
    scanf("%d",&n);
    vector<int> Q;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&v[i],&d[i],&p[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(p[i]>=0)
        {
        ans++;
        Q.push_back(i);
        for(int j=v[i]-1;j>0;j--)
        {
            p[i+v[i]-j]-=j;
        }

        }
        if(p[i]<0)
        {
            for(int j=i-1;j<=n;j++)
            p[j]-=d[i];
        }
}
    cout<<ans<<endl;
    for(int i=0;i<Q.size();i++) cout<<Q[i]<<" ";
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
牙科就诊管理系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了用户在线查看数据。管理员管理病例管理、字典管理、公告管理、药单管理、药品管理、药品收藏管理、药品评价管理、药品订单管理、牙医管理、牙医收藏管理、牙医评价管理、牙医挂号管理、用户管理、管理员管理等功能。牙科就诊管理系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。 管理员在后台主要管理病例管理、字典管理、公告管理、药单管理、药品管理、药品收藏管理、药品评价管理、药品订单管理、牙医管理、牙医收藏管理、牙医评价管理、牙医挂号管理、用户管理、管理员管理等。 牙医列表页面,此页面提供给管理员的功能有:查看牙医、新增牙医、修改牙医、删除牙医等。公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。药品管理页面,此页面提供给管理员的功能有:新增药品,修改药品,删除药品。药品类型管理页面,此页面提供给管理员的功能有:新增药品类型,修改药品类型,删除药品类型。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值