题目链接: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的更多相关文章

  1. 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 ...

  2. 【codeforces 768E】Game of Stones

    [题目链接]:http://codeforces.com/contest/768/problem/E [题意] NIM游戏的变种; 要求每一堆石头一次拿了x个之后,下一次就不能一次拿x个了; 问你结果 ...

  3. [Codeforces Gym] 100162B Circle of Stones

    题意: 桌子上有 n 个石头围成一个环.每个石头都有一种颜色.每种颜色可以由小写英文字母表示.如果每一对相邻的石头都是不同颜色的,则称这 n 个石头构成的环是美丽的.现在,你可以从这 n 个石头中拿走 ...

  4. [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 ...

  5. [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 ...

  6. 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 ...

  7. LeetCode 1000. Minimum Cost to Merge Stones

    原题链接在这里:https://leetcode.com/problems/minimum-cost-to-merge-stones/ 题目: There are N piles of stones ...

  8. LightOJ 1247 Matrix Game (尼姆博弈)

    A - Matrix Game Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submi ...

  9. [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, ...

随机推荐

  1. NX二次开发-NXOpenC++ Example

    NxOpenC++ Example NXOpen::WCS wcs坐标系 https://www.cnblogs.com/nxopen2018/p/11368763.html NXOpen::Draw ...

  2. AutoCAD2016安装破解教程

    AutoCAD2016安装破解教程.本人亲自实验,破解成功,有效.以64位为例. 工具/原料   笔记本电脑 AutoCAD2016安装包 AutoCAD2016注册机(xf-adsk2016_x64 ...

  3. 选择排序-Python & Java

    选择排序:1.找出最小的数值放在第一位2.找出剩余数据中最小的数值放在第二位,以此类推,直到最后一个数值 算法的时间复杂度为:O(n) ''' 选择排序: 1.找出最小的数值放在第一位 2.找出剩余数 ...

  4. tp U函数 logs

    注意 U 函数 项目今天已经搞定了本以为可以上线了没问题了,但是 当我把tp调试模式关闭后:      define('APP_DEBUG',false); 页面完全加载不出来,于是开启:  'SHO ...

  5. plsql初次连接oracle报错解决方案

    windows7 64bit Oracle win64 11gR2(两个文件) PL/SQL v9.0 详细错误信息 Initialization error Could not initialize ...

  6. leetcode 1041——困于环中的机器人

    描述: 在无限的平面上,机器人最初位于 (0, 0) 处,面朝北方.机器人可以接受下列三条指令之一: "G":直走 1 个单位 "L":左转 90 度 &quo ...

  7. Gradle安装配置(Windows)

    在本教程中,我们将学习 Gradle 的安装,对于一个初学者,有时安装开发环境也是一个比较麻烦的问题.如果按照 Gradle 官方网站的说明安装,则可能会遇到一些麻烦,有时还要在互联网上做一些搜索,查 ...

  8. JDK8新特性之方法引用

    什么是方法引用 方法引用是只需要使用方法的名字,而具体调用交给函数式接口,需要和Lambda表达式配合使用. 如: List<String> list = Arrays.asList(&q ...

  9. 两种接口传送数据协议(xml和json)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/tianyazaiheruan/article/details/37659983    规范性接口开发 ...

  10. win10命令行kill进程

    1. 查:netstat -ano | findstr "8080" 2. 杀:taskkill -PID 8082 -F