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, ...
随机推荐
- NX二次开发-NXOpen::Drawings::DrawingSheet Class Reference
NX11+VS2013 #include <NXOpen/Section.hxx> #include <NXOpen/SectionCollection.hxx> #inclu ...
- jmeter之-用Firefox录制https协议证书问题
录制脚本的时候,比如录制https协议的百度网站 https://www.baidu.com ,所有录制设置均正常,但是在jmeter录制控制器里面就是没有任何录制的请求. 这个时候提示说证书不对 1 ...
- SpringBoot中配置不序列化返回值为null的属性
package com.weiresearch.properties; import com.fasterxml.jackson.annotation.JsonInclude;import com.f ...
- Mysql中设置默认时间为系统当前时间
Mysql中设置默认时间为系统当前时间 数据库设计时会遇到的一种情况:将系统当前时间设成默认值存储 数据库设计编码: CREATE TABLE `test` ( `name` varchar(50) ...
- 京东云Ubuntu下安装mysql
1.sudo apt-get install mysql-server,输入y后输入密码 2.sudo apt isntall mysql-client 3.sudo apt install libm ...
- PostgreSQL——服务器配置_{postgresql.conf}
一.设置参数 所有参数名称都是不区分大小写的 值为字符串时,需要单引号 值为数值时不需要单引号,但带单位时,需要单引号 配置文件(如:postgresql.conf.postgresql.auto.c ...
- 获取hdfs集群信息(fs.defaultFS)
[root@hive-dp-7bd6fd4d55-wctjn hive-1.1.0-cdh5.14.0]# hdfs getconf -confKey fs.default.name19/12/04 ...
- beforeEach的深入研究,及beforeEach和beforeRouteEnter区别?
之前一直困惑它俩的区别,也没找到合适的文档,直到有天看到一篇博客,一起来学习下: 之前是在created钩子函数里面,发现这是在今天当前页面之后了.先回顾一下钩子函数beforeEach const ...
- 使用Docker快速部署ELK分析Nginx日志实践
原文:使用Docker快速部署ELK分析Nginx日志实践 一.背景 笔者所在项目组的项目由多个子项目所组成,每一个子项目都存在一定的日志,有时候想排查一些问题,需要到各个地方去查看,极为不方便,此前 ...
- wpf中datagrid绑定数据源发生改变
1.若datagrid绑定的数据源是同一个的话,即使里面的数据不同.页面也不会刷新,则需要重置数据源,再绑定.处理如下: datagrid1.ItemsSource=ListModule; 若List ...