Codeforces 1159A A pile of stones
题目链接:http://codeforces.com/problemset/problem/1159/A
题意:初始石头堆石子数未知,求进行 n 次加减操作后,石头堆石子数最小的可能是多少。
思路:正常模拟就好了,题意理解了老半天orz! 开始数量未知,所以模拟的答案是负数的话,最小可能就是0。
AC代码:
1 #include<iostream> 2 #include<algorithm> 3 #include<string> 4 using namespace std; 5 int main() 6 { 7 int n; 8 char a; 9 cin >> n ; 10 int ans = 0; 11 for(int i = 0;i < n;i++) 12 { 13 cin >> a; 14 if(a == '+') ans++; 15 else if(ans > 0)ans--; 16 } 17 cout << max(ans,0) << endl; 18 return 0; 19 }
转载于:https://www.cnblogs.com/Carered/p/10958213.html
Codeforces 1159A A pile of stones相关推荐
- Codeforces 768E:Game of Stones
Codeforces 768E:Game of Stones 题目链接:http://codeforces.com/contest/768/problem/E 题目大意:给定$n$堆石子,初始每堆$s ...
- A. A pile of stones
题目链接 Vasya has a pile, that consists of some number of stones. n times he either took one stone from ...
- 【CodeForces - 264A】Escape from Stones (模拟,卡精度的处理)
题干: Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a m ...
- Moving stones(暴力+思维)
链接:https://ac.nowcoder.com/acm/contest/5891/D 来源:牛客网 题目描述 One day, GK was getting very bored with pa ...
- 【LeetCode 1000】 Minimum Cost to Merge Stones
题目描述 There are N piles of stones arranged in a row. The i-th pile has stones[i] stones. A move consi ...
- 19级爪哇程序设计新手赛(题解)
19级爪哇程序设计新手赛(题解) A.1+1 HDU - 1228 kk的英语作业,有两个小于100的正整数A和B,计算A+B. A和B由对应的英文单词给出. Input 测试输入包含若干测试用例,每 ...
- E. Tree(The 2019 ACM-ICPC China Shannxi Provincial Programming Contest)(树链剖分+线段树)
4000ms 262144K judge:计蒜客 Description Ming and Hong are playing a simple game called nim game. They h ...
- [Codeforces Round #162 (Div. 2)]A. Colorful Stones (Simplified Edition)
地址:http://codeforces.com/contest/265/problem/A 昨晚没时间参赛 1 #include<stdio.h> 2 #include<strin ...
- CodeForces - 1110E-Magic Stones(差分+思维)
Grigory has nn magic stones, conveniently numbered from 11 to nn. The charge of the ii-th stone is e ...
最新文章
- 强化学习Exploration漫游
- (前)首富许家印造车果然有一套:车还没量产上市,公司先冲刺科创板募资
- python中如何跳出多层循环
- 隐藏esp_?吉利帝豪GL到店实拍,7.78万起,配鹰眼LED大灯+ESP,家用首选
- VTK:环境球AmbientSpheres用法实战
- ajax接收到的数据是一个页面的代码的原因
- N76E003---看门狗
- 创建Git仓库的三种形式
- mac下安装elasticsearch
- java对图像的解压_java – 将图像解压缩到blobstore中
- ABBYY PDF Transformer+功能概述
- [转]将c#中datagridview中的数据导出到excel中
- 个人推荐讲的非常好的数据结构免费[速成 速成 速成]视频了
- CASE WHEN THEN 判断
- Frequent values ——RMQ
- java验证图片大小_java 校验图片的大小、尺寸、比例
- PHP编程 967 个函式 值得收藏
- 怎么训练神经网络模型,神经网络模型训练过程
- “空天地海”一体化的海上应急通信网络技术综述
- Activity的数据回传——案例:装备选择
热门文章
- VC++如何处理自定义消息
- bcb中使用pas文件
- bash-高级编程--变量和参数介绍
- 不确定mysql是否安装成功了怎么办
- 指针:自定义函数length,调用它计算字符串的长度
- Android PC投屏简单尝试—最终章1
- 以太坊智能合约生命周期(Ethereum smart contracts lifecycle)
- mysql 值到99999后不增值了_Mysql 增加新数据,若存在则更新的问题
- v4l2 框架下如何设置分辨率_如何在端外投放的场景下实现前端实时CEP框架?
- python数字转对应中文_python中将阿拉伯数字转换成中文的实现代码 | 学步园