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, ...
随机推荐
- ORACLE动态sql在存储过程中出现表或视图不存在的解决方法
Oracle动态sql在存储过程中出现表或视图不存在的解决方法 CREATE OR REPLACE PROCEDURE P_test is strsql varchar2(2000); BEGIN ...
- spring 对JDBC的支持 (8)
目录 一.jdbc的简介 二.jdbcTemplate 的使用 2.1 maven 引入spring - jdbc ,c3p0 ,数据库mysql驱动 2.2 配置 数据源以及jdbcTemplate ...
- JAVA JDBC大数据量导入Mysql
转自https://blog.csdn.net/q6834850/article/details/73726707?tdsourcetag=s_pctim_aiomsg 采用JDBC批处理(开启事务. ...
- Dubbo入门到精通学习笔记(八):ActiveMQ的安装与使用(单节点)、Redis的安装与使用(单节点)、FastDFS分布式文件系统的安装与使用(单节点)
文章目录 ActiveMQ的安装与使用(单节点) 安装(单节点) 使用 目录结构 edu-common-parent edu-demo-mqproducer edu-demo-mqconsumer 测 ...
- Codeforces 1189B Number Circle
题目链接:http://codeforces.com/problemset/problem/1189/B AC代码: #include<bits/stdc++.h> using names ...
- JavaScript深浅拷贝区别
分享一篇自己关注的微信订阅号(前端大全)文章:JavaScript浅拷贝与深拷贝 作者:浪里行舟 https://github.com/ljianshu/Blog/issues/5 这里很详细的讲解了 ...
- vSphere ESXi如何使用嵌套虚拟化(1-vSphere 6.0+linux虚拟化)
今天准备在vSphere当中上传一个用workstation做出来的虚拟机,没想到遇到了很多问题,在这里,作为新手小白碰到了一些问题,在这里总结一下. 1.workstation做出来的虚拟机直接上传 ...
- 读书笔记五--numpy
数组转置和轴对换 转置是重塑的一种特殊形式,返回的是源数据的视图(不会进行任何复制操作).数组不仅有transpose方法,还有一个特殊的T属性: arr=np.arange().reshape((, ...
- [HDU3333]Turing Tree
莫队模板题... 不过树状数组也可以做...跟HH的项链几乎一模一样,离线询问,然后记录前缀,更新的时候把前缀删掉就好了,然而这题开long long,卡空间 //hgs AK IOI,IMO,ICH ...
- PHP - 实现 strStr()
实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存在,则返 ...