Codeforces 1159A A pile of stones
题目链接:http://codeforces.com/problemset/problem/1159/A


题意:初始石头堆石子数未知,求进行 n 次加减操作后,石头堆石子数最小的可能是多少。
思路:正常模拟就好了,题意理解了老半天orz! 开始数量未知,所以模拟的答案是负数的话,最小可能就是0。
AC代码:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int n;
char a;
cin >> n ;
int ans = ;
for(int i = ;i < n;i++)
{
cin >> a;
if(a == '+') ans++;
else if(ans > )ans--;
}
cout << max(ans,) << endl;
return ;
}
Codeforces 1159A A pile of stones的更多相关文章
- Codeforces 768 E. Game of Stones 博弈DP
E. Game of Stones Sam has been teaching Jon the Game of Stones to sharpen his mind and help him de ...
- 【codeforces 768E】Game of Stones
[题目链接]:http://codeforces.com/contest/768/problem/E [题意] NIM游戏的变种; 要求每一堆石头一次拿了x个之后,下一次就不能一次拿x个了; 问你结果 ...
- [Codeforces Gym] 100162B Circle of Stones
题意: 桌子上有 n 个石头围成一个环.每个石头都有一种颜色.每种颜色可以由小写英文字母表示.如果每一对相邻的石头都是不同颜色的,则称这 n 个石头构成的环是美丽的.现在,你可以从这 n 个石头中拿走 ...
- [LeetCode] 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 consists ...
- [Swift]LeetCode1000. 合并石头的最低成本 | 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 consists ...
- 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 consists ...
- LeetCode 1000. Minimum Cost to Merge Stones
原题链接在这里:https://leetcode.com/problems/minimum-cost-to-merge-stones/ 题目: There are N piles of stones ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- [Swift]LeetCode877. 石子游戏 | Stone Game
Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, ...
随机推荐
- lvs+keepalived+mariadb集群
1.环境准备节点1:172.16.2.95节点2:172.16.2.160节点3:172.16.2.220LVS1:172.16.2.67LVS2:172.16.2.234 2.mariadb集群的安 ...
- 3-基于LoG的特征检测子
- Extjs各版本的下载链接,包含ext3.4源码示例
最近在维护一个老平台,用的是ext3.4,老东西在网上找示例发现既然还有人收钱,谷歌了一下总算找到了一位免费的发布的,感谢 yipanbo 分享 Extjs的版本繁多,本文收集了Extjs各个版本的下 ...
- 【Shiro】一、Apache Shiro简介
一.Apache Shiro简介 1.简介 一个安全性框架 特点:功能丰富.使用简单.运行独立 核心功能: Authentication(认证):你是谁? Authorization(授权):谁能干什 ...
- Peer模式的多线程程序例子
Peer模式的多线程程序例子 程序的模型大概是这样的.有一个master(),用来分发任务.有N个多线程的slave用来处理任务. 主程序里可以这样调用: 可以看出,上面这段程序还是依赖于Proces ...
- JAVA学习之Java程序开发初次体验
Java环境搭建算完成了,那么接下来写个Java程序走一个 开发Java程序的简单流程 1.将Java代码编写到扩展名为.java的文件中2.通过javac命令对该Java文件进行编译(生成class ...
- iptables防DDOS攻击和CC攻击配置
防范DDOS攻击脚本 #防止SYN攻击 轻量级预防 iptables -N syn-flood iptables -A INPUT -p tcp –syn -j syn-flood iptables ...
- mysql优化1:建表原则
建表三大原则: 定长和变长分离 常用字段和不常用字段分离 使用冗余字段或冗余表 1.定长与变长分离 如 id int,占4个字节,char(4)占4个字符长度,也是定长,time 即每一个单元值占的字 ...
- python_learn Ⅰ
基于 廖雪峰python3教程 学习. 目录: 01_输入输出.py 02_list.tuple.py 03_条件判断.py 04_循环.py 05_利用循环排序.py 06_自定义3元2次方程的根求 ...
- 实现简单的PHP接口,以及使用js/jquery ajax技术调用此接口
主要介绍下如何编写简单的php接口,以及使用js/jquery的ajax技术调用此接口. Php接口文件(check.php): <?php $jsonp_supporter = $_GET[‘ ...