[ An Ac a Day ^_^ ] CodeForces 586C Gennady the Dentist 模拟
题意:
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 模拟的更多相关文章
- CodeForces - 586C Gennady the Dentist 模拟(数学建模的感觉)
http://codeforces.com/problemset/problem/586/C 题意:1~n个孩子排成一排看病.有这么一个模型:孩子听到前面的哭声自信心就会减弱:第i个孩子看病时会发出v ...
- 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 ...
- 【16.23%】【codeforces 586C】Gennady the Dentist
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- CodeForces 670 A. Holidays(模拟)
Description On the planet Mars a year lasts exactly n days (there are no leap years on Mars). But Ma ...
- 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 ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- Codeforces 1373F - Network Coverage(模拟网络流)
Codeforces 题面传送门 & 洛谷题面传送门 提供一个模拟网络流的题解. 首先我们觉得这题一脸可以流的样子,稍微想想可以想到如下建图模型: 建立源点 \(S,T\) 和上下两排点,不妨 ...
- Codeforces Good Bye 2016 D 模拟搜索?
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...
随机推荐
- MyBatis 学习-与 Spring 集成篇
根据官方的说法,在 ibatis3,也就是 Mybatis3 问世之前,Spring3 的开发工作就已经完成了,所以 Spring3 中还是没有对 Mybatis3 的支持.因此由 Mybatis 社 ...
- vb.net 结束进程
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ...
- iOS参考工具和资源
图片: Glyphish(图标资源) 资源: SwiftGuide:这份指南汇集了Swift语言主流学习资源,并以开发者的视角整理编排. 27款iOS开源库,让你的开发溜到飞起 创业者的新春礼包—优秀 ...
- ASP.NET使用ImageMap控件
文章来自:http://www.baike369.com/content/?id=5773
- WinForm 无边框窗体和timer控件
一.无边框窗体 1.控制按钮如何制作就是放置可以点击的控件,不局限于使用按钮或是什么别的,只要可以点击能触发点击事件就可以了 做的好看一点,就是鼠标移入,移出,按下三个事件会让按钮改变样式 如何获取图 ...
- [WPF] 为Style 里的button添加鼠标点击响应事件
一个TabControl, 用的是PagedTabControl style, 在style中有个button, button在style里已经写了click事件,但是现在还需要加上一段功能,就是在响 ...
- 用PhotoSwipe制作相册,手势可放大
1.引入css和js <link href="css/photoswipee.css" rel="stylesheet" type="text/ ...
- Namespacing in PHP (php 中使用命名空间)
最近学习一下php的命名空间,中文文档不多,搜到一篇英文的,讲的还蛮系统的,特此翻译一下,以备以后查阅,大家有什么高见或更深刻或者 更悟透的见解希望能不吝赐教,晚辈感激不尽. 原文: http://c ...
- Nis+Nfs+Autofs
Nis: NIS服务的应用结构中分为NIS服务器和NIS客户机两种角色 NIS服务器集中维护用户的帐号信息(数据库)供NIS客户机进行查询 用户登录任何一台NIS客户机都会从NIS服务器进行登录认证, ...
- ramfs/tmpfs: Linux RAM filesystems
Previously in windows, I uses ramdisk, to accelerate chrome browsing. However, in linux, this is mad ...