首页 > 其他分享 >字符串+匹配

字符串+匹配

时间:2025-01-12 10:22:16浏览次数:8  
标签:XXL1 XXL2 匹配 min ++ else int 字符串

https://codeforces.com/gym/580226/problem/C

#include<bits/stdc++.h>
#define lc p<<1
#define rc p<<1|1
#define INF 2e9
using namespace std;

#define endl '\n'
using ll = long long;
using pii = pair<ll, ll>;
const double PI = acos(-1);
const int N=1e4+10;

void solve(){
	int S1=0,M1=0,L1=0;
	int XS1=0,XL1=0;
	int XXS1=0,XXL1=0;
	int XXXS1=0,XXXL1=0;
	int S2=0,M2=0,L2=0;
	int XS2=0,XL2=0;
	int XXS2=0,XXL2=0;
	int XXXS2=0,XXXL2=0;
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		string s;cin>>s;
		if(s=="S") S1++;
		else if(s=="M") M1++;
		else if(s=="L") L1++;
		else if(s=="XS") XS1++;
		else if(s=="XL") XL1++;
		else if(s=="XXL") XXL1++;
		else if(s=="XXS") XXS1++;
		else if(s=="XXXL") XXXL1++;
		else XXXS1++;
	}
	for(int i=1;i<=n;i++){
		string s;cin>>s;
		if(s=="S") S2++;
		else if(s=="M") M2++;
		else if(s=="L") L2++;
		else if(s=="XS") XS2++;
		else if(s=="XL") XL2++;
		else if(s=="XXL") XXL2++;
		else if(s=="XXS") XXS2++;
		else if(s=="XXXL") XXXL2++;
		else XXXS2++;
	}
	ll ans=min(S1,S2)+min(M1,M2)+min(L1,L2)+min(XS1,XS2)+min(XL1,XL2)+min(XXL1,XXL2)+min(XXS1,XXS2)+min(XXXL1,XXXL2)+min(XXXS1,XXXS2);
//	cout<<ans<<endl;
	cout<<n-ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	
	int T = 1;
//	cin>>T;
	while (T--) {
		solve();
	}
	
	return 0;
}



标签:XXL1,XXL2,匹配,min,++,else,int,字符串
From: https://www.cnblogs.com/laileou/p/18666733

相关文章