题意:

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. python第五天

    反射 hasattr,getattr class Foo: static_name = 'nba' def __init__(self): self.name = 'alex' def show(se ...

  2. zabbix 布署实践【6 使用微信公众号-消息模版推送告警】

    使用这个服务的前提是,你必须要有一个微信订阅号,或者公众号,并且是通过认证的号 因为认证过后的号才有模版消息和获取用户openid等信息的权限 ,如下,登录微信公众号的登录页后,底下有个接口权限的展示 ...

  3. 【hihoCoder 1466】后缀自动机六·重复旋律9

    http://hihocoder.com/problemset/problem/1466 建出A串和B串的两个后缀自动机 对后缀自动机的每个状态求出sg值. 求出B串的\(sum(x)\),表示B有多 ...

  4. PAT乙级1004. 成绩排名 (20)

    读入n名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. 输入格式:每个测试输入包含1个测试用例,格式为 第1行:正整数n 第2行:第1个学生的姓名 学号 成绩 第3行:第2个学生 ...

  5. C# 语言规范_版本5.0 (第17章 特性)

    1. 特性 C# 语言的一个重要特征是使程序员能够为程序中定义的实体指定声明性信息.例如,类中方法的可访问性是通过使用 method-modifiers(public.protected.intern ...

  6. 主机无法访问虚拟机的httpd服务

    症状:虚拟机装的centos6.3 通过桥接的方式与主机连接 虚拟机通过yum安装httpd服务 在主机浏览器中输入 虚拟机ip  无法访问虚拟机Apache 虚拟机和主机可以相互ping通 解决:关 ...

  7. bootstrap页面模板

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  8. C# 手机格式验证

    C# 手机格式验证 //电信手机号码正则 Regex dReg = new Regex(@"^1[3578][01379]\d{8}$"); //联通手机号正则 Regex tRe ...

  9. PHP mktime函数获取今天的开始和结束时间戳

    php 获取今日.昨日.上周.本月的起始时间戳和结束时间戳的方法,主要使用到了 php 的时间函数 mktime(). mktime函数用法如下:mktime(hour,minute,second,m ...

  10. Vue.js + Seajs 实例(包含vue-router使用)

    这个Demo 相关JS: Sea.js : Version 2.3.0 seajs-text :  Version 2.3.0 vue.js : Version 1.0.24 vue-router: ...