General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
45408906 Practice:
Jester
1070J - 29 GNU C++14 Accepted 93 ms 204 KB 2018-11-07 14:08:19 2018-11-07 14:08:19
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
bool dp[N];
int freq[26],n,m,k,sum,ans;
char c;
int main(){
// 	freopen("readin.txt","r",stdin);
	int T;
	scanf("%d",&T);
	while(T--){
		sum = 0;
		ans = 1e9;
		memset(freq,0,sizeof freq);
		scanf("%d%d%d",&n,&m,&k);
		sum = k;
		for(int i = 0;i < k;i++){
			scanf(" %c",&c);
			freq[c - 'A']++;
		}
		for(int at = 0;at < 26;at++){
			sum = k - freq[at];
			for(int i = 0;i <= sum;i++)dp[i] = 0;
			dp[0] = 1;
			for(int i = 0;i < 26;i++)
				if(i != at)
					for(int j = sum - freq[i];j >= 0;j--)dp[j + freq[i]]|=dp[j];
			for(int i = 0;i <= sum;i++){
				if(!dp[i])continue;
				int a = max(0,n - i);
				int b = max(0,m - sum + i);
				if(a + b > freq[at])continue;
				ans = min(ans,a*b);
			}
		}
		printf("%d\n",ans);
	}
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details