#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
ll a[1009],b[1009];
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(j=0;j<n;j++)
{
cin>>b[j];
}
sort(a,a+n);
sort(b,b+n);
ll cnt=0;
for(i=0;i<n;i++)
{
if(a[i]==-1)
continue;
ll in;
bool flag=0;
for(j=0;j<n;j++)
{
if(b[j]==-1)
continue;
else
{
if(a[i]>b[j])
{
flag=1;
in=j;
}
}
}
if(flag)
{
a[i]=b[in]=-1;
cnt+=2;
}
}
for(i=0;i<n;i++)
{
if(a[i]==-1)
continue;
for(j=0;j<n;j++)
{
if(b[j]==-1)
continue;
else
{
if(a[i]==b[j])
{
a[i]=b[j]=-1;
cnt+=1;
break;
}
}
}
}
cout<<"Case "<<k<<": "<<cnt<<endl;
}
return 0;
}
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
ll a[1009],b[1009];
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(j=0;j<n;j++)
{
cin>>b[j];
}
sort(a,a+n);
sort(b,b+n);
ll cnt=0;
for(i=0;i<n;i++)
{
if(a[i]==-1)
continue;
ll in;
bool flag=0;
for(j=0;j<n;j++)
{
if(b[j]==-1)
continue;
else
{
if(a[i]>b[j])
{
flag=1;
in=j;
}
}
}
if(flag)
{
a[i]=b[in]=-1;
cnt+=2;
}
}
for(i=0;i<n;i++)
{
if(a[i]==-1)
continue;
for(j=0;j<n;j++)
{
if(b[j]==-1)
continue;
else
{
if(a[i]==b[j])
{
a[i]=b[j]=-1;
cnt+=1;
break;
}
}
}
}
cout<<"Case "<<k<<": "<<cnt<<endl;
}
return 0;
}
No comments:
Post a Comment