UVALive - 7270 Osu! Master

/*
  这题我觉得最关键的地方不在写代码,而是看懂题意,我读题时,其实是没那么快理解题目是要我们做什么的
  
  以及,值得一提的是,之前我一直以为,应该把last记录下来,但是后来发现根本没有必要,直接记录下ans就行,每次遇到S,ans更新,遇到非S的字母和为1的数组,ans更新,和非1的数字一点关系都没有,换言之,1后面的数字不一定要满足 1 2 3 4这种关系,如果我是1 3 5,也可以算作一个pattern,下次遇到数字1或者字母S,才相当于进入下一个pattern
  
  以及,这个点是在看这个blog时发现的,这个博主看问题真是一眼看到本质...
  http://blog.csdn.net/kim0403/article/details/52144271
  
  于是发现,这题根本就不需要记录上一个数字啊...我果然还是题目做太少了,sigh
*/


#include<iostream>
using namespace std;
//#define debug

int main()
{
	#ifdef debug 
	freopen("E:\\in.txt", "r", stdin);
	freopen("E:\\out.txt", "w", stdout);
	#endif
	
	int n, num, last, ans = 0;
	string str;
	while (cin >> n)
	{
		last = 0, ans = 0;
		while (n--)
		{
			cin >> str;
			if (str != "S") 
			{
				cin >> num;
				if (num == 1) ans++, last = 1;
				else if (num == last + 1) last++;
			}
			else
			ans++, last = 0;
		}
		cout << ans << endl;
	}
	
	#ifdef debug
	fclose(stdin);
	fclose(stdout);
	#endif

	return 0;
}


转载于:https://www.cnblogs.com/mofushaohua/p/7789545.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值