zoukankan      html  css  js  c++  java
  • Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力

    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​​,Ci​​,即此题的初始分值、每分钟减少的分值、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[4005],d[4005],p[4005];
    long long ans[4005];
    long long flag[4005];
    int n;
    int main()
    {
        memset(flag,0,sizeof(flag));
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%lld%lld%lld",&v[i],&d[i],&p[i]);
        int tot = 0;
        for(int i=1;i<=n;i++)
        {
            if(p[i]<0)continue;
            ans[tot++]=i;
            long long sum=0;
            long long time = v[i];
            for(int j=i+1;j<=n;j++)
            {
                flag[j]=0;
                if(p[j]>=0)
                {
                    flag[j]=1;
                    if(time>0)
                        p[j]-=time;
                    time--;
                }
            }
            for(int j=i+1;j<=n;j++)
            {
                if(p[j]>=0)
                    p[j]-=sum;
                if(p[j]<0&&flag[j])
                    sum+=d[j];
            }
        }
        printf("%d
    ",tot);
        for(int i=0;i<tot;i++)
            printf("%lld ",ans[i]);
        printf("
    ");
    }
  • 相关阅读:
    qt setfixedsize以后怎么让窗口可正常resize
    总线操作使用工具
    DTK 获取活动色
    qt 设置背景色
    python_itchat模块登陆问题
    python_基础知识
    python_爬虫_str类型的html文本去标签
    工作__问题
    服务器_sshfs的安装、挂载、取消挂载
    python_爬虫_通过selenium获取人人网cookie值并模拟登陆个人界面
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4873929.html
Copyright © 2011-2022 走看看