General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44599761 Practice:
ydnhaha
1070J - 29 GNU C++11 Accepted 93 ms 800 KB 2018-10-20 16:48:45 2018-10-20 16:48:45
 
 
→ Source
#pragma GCC optimize(2)
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
int T,n,m,k,len,ans;
int cnt[30],dp[N];
char rd[N];
bool cmp(int a,int b)
{
	return a>b;
}
void init()
{
	len=strlen(rd+1),ans=n*m;
	memset(cnt,0,sizeof cnt);
	for(int i=1;i<=len;i++)
		cnt[rd[i]-'A'+1]++;
}
int main ()
{
	register int i,j,h;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		scanf("%s",rd+1),init();
		for(i=1;i<=26;i++)
		{
			for(j=1;j<=k;j++) dp[j]=0; dp[0]=1;
			for(j=1;j<=26;j++)
				if(j!=i)
					for(h=k;h>=cnt[j];h--)
						dp[h]|=dp[h-cnt[j]]; 
			for(j=0;j<=k;j++)
				if(dp[j])
				{
					int xx=max(0,n-j),yy=max(0,m-(k-cnt[i]-j));
					if(xx+yy<=cnt[i]) ans=min(ans,xx*yy); 
				}
		}
		printf("%d\n",ans);
	}
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details