题意:

n个小朋友去拔牙 每个小朋友在拔牙的时候会哭 哭声是vi分贝

距离门口vi远的小朋友听到了哭声会害怕 他们的勇气值p会减少d

如果勇气值p小于等于零 他们就会在门外哭并立即离开拔牙队列(回家找妈妈……)

这个哭声门外所有的小朋友都能听到 所以这个哭声会同时减少所有小朋友的勇气值

问最后有多少小朋友可以拔完牙

思路:

就是模拟一下这个过程

好像后面的小朋友哭了对前面的小朋友没有影响

WA了一次是因为结构体里没用long long……

 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
struct child{
ll vi,d,p;
}child[];
int cnt=,ans[];
int main(){
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%I64d%I64d%I64d",&child[i].vi,&child[i].d,&child[i].p);
for(int i=;i<=n;i++){
if(child[i].p<) continue;
ans[cnt++]=i;
ll v=child[i].vi,cry=;
for(int j=i+;j<=n;j++){
if(child[j].p<) continue;
child[j].p-=v+cry;
v--;
if(v<) v=;
if(child[j].p<) cry+=child[j].d;
}
}
printf("%d\n",cnt);
for(int i=;i<cnt;i++)
printf("%d%c",ans[i],i==cnt-?'\n':' ');
return ;
}
/* 5
4 2 2
4 1 2
5 2 4
3 3 5
5 1 2 5
4 5 1
5 3 9
4 1 2
2 1 8
4 1 9 */

[ An Ac a Day ^_^ ] CodeForces 586C Gennady the Dentist 模拟的更多相关文章

  1. CodeForces - 586C Gennady the Dentist 模拟(数学建模的感觉)

    http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v ...

  2. 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 ...

  3. 【16.23%】【codeforces 586C】Gennady the Dentist

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

  4. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  5. CodeForces 670 A. Holidays(模拟)

    Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...

  6. Codeforces 1090B - LaTeX Expert - [字符串模拟][2018-2019 Russia Open High School Programming Contest Problem B]

    题目链接:https://codeforces.com/contest/1090/problem/B Examplesstandard input The most famous characters ...

  7. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  8. Codeforces 1373F - Network Coverage(模拟网络流)

    Codeforces 题面传送门 & 洛谷题面传送门 提供一个模拟网络流的题解. 首先我们觉得这题一脸可以流的样子,稍微想想可以想到如下建图模型: 建立源点 \(S,T\) 和上下两排点,不妨 ...

  9. Codeforces Good Bye 2016 D 模拟搜索?

    给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...

随机推荐

  1. [MFC美化] SkinSharp使用详解1-使用方法

    需要注意的是: 加载换肤后,程序关闭时,无需调用卸载皮肤接口,SkinSharp换肤库会自己完成清理工作.换肤时无需卸载皮肤,直接调用即可. 其DLL使用方法与前面几种皮肤库用法类似.如下: 1. 将 ...

  2. PHP 在 Nginx 下主动断开连接 Connection Close 与 ignore_user_abort 后台运行

    这两天弄个PHP调用 SVN 同步 update 多台服务器更新的程序,为了避免 commit 的时候不会被阻塞卡半天得想个办法只请求触发,而不需要等待程序 update 完成返回结果这样耗时太长,所 ...

  3. js数组操作-找出一组按不同顺序排列的字符串的数组元素

    从一组数组中找出一组按不同顺序排列的字符串的数组元素将字符串转换成数组后再对数组进行 sort 排序,abcd 和 bdca 使用 sort 排序后会变成 abcd,将拍好序的字符串作为对象的 key ...

  4. Unity 解决 An asset is marked with HideFlags.DontSave but is included in the build 问题。

    问题是:不能使用Unity使用的默认的字体.想要显示中文直接去下载一个字体.没必要使用默认的字体

  5. html和html5学习

    html和html5学习 chorme.safari中的input或textarea html超链接(a)详细讲解 html5新增及删除标签 html表格 图片加alt属性 input的type属性 ...

  6. [转] 你真的会写单例模式吗——Java实现

    你真的会写单例模式吗——Java实现 原文:http://www.tuicool.com/articles/MBrUfy6 单例模式可能是代码最少的模式了,但是少不一定意味着简单,想要用好.用对单例模 ...

  7. SAP HANA 创建属性视图

    [Step By Step]SAP HANA创建属性视图(Attribute View) Demo Instruction: 从一张用户信息表中组合出相信地址. 1. 在modeler窗口中,找到相应 ...

  8. mongodb (一)

    #mongodb安装(3.4.0) #下载安装包,解压 mkdir /data/mongodb cd /data/mongodb mkdir log conf data bin vim conf/mo ...

  9. MSMQ小Demo

    Demo基于http://www.cnblogs.com/zhili/p/MSMQ.html Server代码: using System.Messaging; using System.Text; ...

  10. Redis14--jedis实现主从模式。

    redis的主从模式之前提到过,这里我们使用redis来实现主从模式.首先在VMware虚拟机中的Linux中打开两个终端,一个是用户jack,一个是newuser:然后我们jack作为主机,redi ...