HDU6536 Hello XTCPC(2019JSCPC E题)

Hello XTCPC

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 981    Accepted Submission(s): 271

Problem Description

You have a string of lowercase letters.You need to find as many sequence “xtCpc” as possible.But letters in the same position can only be used once。

Input

The input file contains two lines.

The first line is an integer n show the length of string.(1≤n≤2×105)

The second line is a string of length n consisting of lowercase letters and uppercase letters.

Output

The input file contains an integer show the maximum number of different subsequences found.

Sample Input

10 xtCxtCpcpc

Sample Output

2

Source

2019CCPC湖南全国邀请赛(广东省赛、江苏省赛)重现赛

原来题目是JSCPC,被改成了XTCPC

直接遍历一遍就OK了,但是要循环输入(题目里也没说啊)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 200005
int a[5];
int main()
{
	char s[N];
	int n;
	while(~scanf("%d%s",&n,&s)){
		memset(a,0,sizeof(a));
		for(int i=0;i<n;++i){
			if(s[i]=='x') a[0]++;
			else if(s[i]=='t'){
				if(a[0]){
					a[1]++, a[0]--;
				}
			}else if(s[i]=='C'){
				if(a[1]){
					a[2]++, a[1]--;
				}
			}else if(s[i]=='p'){
				if(a[2]){
					a[3]++, a[2]--;
				}
			}else if(s[i]=='c'){
				if(a[3]){
					a[4]++, a[3]--;
				}
			}
		}
		cout<<a[4]<<endl;
	}
	return 0;
}

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值