WA了两个点,找不出错误,求神犇
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N=2e5+10,inf=0x3f3f3f3f,mod=1e9+7;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
map<int,int> m,e,check;
ll cntm,cnte,n,a[N],sum;
string s;
int main(){
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
cin>>s;
for(int i=0;i<n;i++){
if(s[i]=='M') m[a[i]]++;
if(s[i]=='E') for(auto j:m) e[j.x*10+a[i]]+=j.y;
if(s[i]=='X'&&e.size()){
for(auto j:e){
check[0]=check[1]=check[2]=check[3]=1;
check.erase(a[i]),check.erase(j.x%10),check.erase(j.x/10);
sum+=check.begin()->x*j.y;
}
}
}
cout<<sum;
return 0;
}