# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
64278658 |
Practice:
vjudge4 |
1070J
- 29
|
GNU C++11
|
Accepted
|
155 ms
|
324 KB
|
2019-11-05 02:49:05 |
2019-11-05 02:49:05 |
|
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e4+5,M=2e5+5;
ll cnt[26];
int f[N];
char s[M];
int main(){
int T;scanf("%d",&T);
f[0]=1;
while(T--){
ll n,m,k,ans=1e18;
memset(cnt,0,sizeof(cnt));
scanf("%lld%lld%lld%s",&n,&m,&k,s+1);
ll d=k-n-m;
// if(n<m)swap(n,m);
for(int o=1;o<=k;o++)cnt[s[o]-'A']++;
for(int i=0;i<26;i++){
for(int s=1;s<=n;s++)f[s]=0;
for(int j=0;j<26;j++){
if(j==i)continue;
for(int s=n;s>=cnt[j];s--)f[s]|=f[s-cnt[j]];
}
for(int j=min(cnt[i],n);j>=0;j--){
if(!f[n-j])continue;
ans=min(ans,max(0ll,cnt[i]-j-d)*j);
}
}
cout<<ans<<endl;
}
return 0;
}
Click to see test details