您的位置:首页 > 其它

CROC-MBTU 2012, Elimination Round / 245E Mishap in Club (想法题)

2014-03-09 11:03 429 查看
http://codeforces.com/problemset/problem/245/E

画个函数图像你就知道代码怎么写了。

/*30ms,0KB*/

#include<bits/stdc++.h>
using namespace std;
const int mx = 305;

char s[mx];

int main()
{
	gets(s);
	int cnt = 0, ans = 0;
	for (int i = 0; s[i]; ++i)
	{
		if (s[i] == '+')
		{
			++cnt;
			ans = max(ans, cnt);
		}
		else
		{
			--cnt;
			if (cnt < 0)
			{
				cnt = 0;
				++ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐