题目大意:题目连接
按照输入的看最后有多少个Shock
解体思路:
根据C B S 维护x
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
char ch;
int a;
int ans;
int t;
int p;
// freopen("t.txt","r",stdin);
while(scanf("%d",&t)!=EOF){
if(t==0) {
printf("0\n");
continue;
}
p=-1;
ans=0;
for(int i=0;i<t;i++){
cin>>ch;
if(ch=='S'){
p=-1;
ans++;
}
else{
cin>>a;
if(a!=p+1)
ans++;
p=a;
}
}
printf("%d\n",ans);
}
return 0;
}