队列处理
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdio>
using namespace std;
queue<int> j,s,C,p,c;
const int MAXN=2e5+10;
char str[MAXN];
int main()
{
int n;
while(~scanf("%d",&n))
{
while(!j.empty()) j.pop();
while(!s.empty()) s.pop();
while(!C.empty()) C.pop();
while(!p.empty()) p.pop();
while(!c.empty()) c.pop();
scanf("%s",str);
for(int i=0;i<n;i++)
{
if(str[i]=='x') j.push(i);
else if(str[i]=='t') s.push(i);
else if(str[i]=='C') C.push(i);
else if(str[i]=='p') p.push(i);
else if(str[i]=='c') c.push(i);
}
int ans=0;
while(!j.empty())
{
if(s.empty()||C.empty()||p.empty()||c.empty())
break;
else
{
int k1=j.front();
while(s.front()<k1&&!s.empty()) s.pop();
if(s.empty()) break;
int k2=s.front();
while(C.front()<k2&&!C.empty()) C.pop();
if(C.empty()) break;
int k3=C.front();
while(p.front()<k3&&!p.empty()) p.pop();
if(p.empty()) break;
int k4=p.front();
while(c.front()<k4&&!c.empty()) c.pop();
if(c.empty()) break;
j.pop();s.pop();C.pop();p.pop();c.pop();
ans++;
}
}
printf("%d\n",ans);
}
return 0;
}