[ 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 ...
随机推荐
- wpf 界面线程 添加项
foreach (var r in sec.Records) { listView.Dispatcher.Invoke((new Action(delegate() { listView.Items. ...
- USACO 3.3 TEXT Eulerian Tour中的Cows on Parade一点理解
Cows on Parade Farmer John has two types of cows: black Angus and white Jerseys. While marching 19 o ...
- c# 强制退出程序
引用:http://blog.csdn.net/tanhua103292/article/details/4283203 1.强制退出WinForm程序之Application.Exit和Enviro ...
- 第一百一十七节,JavaScript,DOM元素尺寸和位置
学习要点: 1.获取元素CSS大小 2.获取元素实际大小 3.获取元素周边大小 本章,我们主要讨论一下页面中的某一个元素它的各种大小和各种位置的计算方式,以便更好的理解. 一.获取元素CSS大小 1. ...
- Java的URL来下载网页源码
import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; impor ...
- Unity 解决 An asset is marked with HideFlags.DontSave but is included in the build 问题。
问题是:不能使用Unity使用的默认的字体.想要显示中文直接去下载一个字体.没必要使用默认的字体
- webAPI---发布(IIS)--发布遇到问题(500.19,500.21,404.8,404.3)
WebAPI的内容部分直接转自官方文档,英语水平有限,不做翻译, 发布网站在本文的后半部分 HTTP is not just for serving up web pages. It is also ...
- delphi const
参考:http://www.cnblogs.com/tibetwolf/articles/1785744.html 1.const修饰可能会优化编译代码.关于这一点与编译器密切相关,由于变量被cons ...
- linux awk命令详解2
awk是行处理器: 相比较屏幕处理的优点,在处理庞大文件时不会出现内存溢出或是处理缓慢的问题,通常用来格式化文本信息 awk处理过程: 依次对每一行进行处理,然后输出 awk命令形式: awk [-F ...
- 子字符查找KMP算法 - 子串自匹配索引表
public static int[] kmpTable(char[] seq) { int[] tbl = new int[seq.length]; tbl[0] = 1; for (int i = ...