General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
45984419 Practice:
vjudge1
1070J - 29 GNU C++11 Accepted 139 ms 4904 KB 2018-11-20 08:14:58 2018-11-20 08:14:58
 
 
→ Source
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
const int M = 1000010;
int num[110],f[M],n,m,K;
char s[M];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d%s",&n,&m,&K,s+1);
		memset(num,0,sizeof(num));
		for(int i=1;i<=K;i++)
			num[s[i]-'A'+1]++;
		long long ans=INF;
		int h=K-n-m;
		if(n<m)
			swap(n,m);
		f[0]=1;
		for(int i=1;i<=26;i++)
		{
			for(int j=1;j<=n;j++)
				f[j]=0;
			for(int j=1;j<=26;j++)
			{
				if(i==j)
					continue;
				for(int k=n;k>=num[j];k--)
					f[k]|=f[k-num[j]];		
			}
			for(int j=min(n,num[i]);j>=0;j--)
			{
				if(!f[n-j])
					continue;
				ans=min(ans,(long long)j*max(0,num[i]-j-h)); 
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details