General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
50503455 Practice:
Photon_
1070J - 29 C++17 (GCC 7-32) Accepted 187 ms 1300 KB 2019-02-25 21:23:01 2019-02-25 21:23:01
→ Source
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t,n,m,k;
    string s;
    cin>>t;
    while(t--)
    {
        cin>>n>>m>>k>>s;
        int skip = k-n-m;
        if(m > n)swap(n,m);
        int A[256]={};
        for(auto&ch:s)A[ch]++;

        ll ats = LLONG_MAX/10;

        for(int i='A'; i<='Z'; i++)
        {
            int left = k-A[i];
            vector<int>DP(k+1);
            DP[0]=1;

            for(int j='A'; j<='Z'; j++)
                if(i!=j)
                for(int z=k-A[j]; z>=0; z--)
                    if(DP[z])DP[z+A[j]]=1;

            for(ll j=0; j<=min(A[i],n); j++)
                if(DP[n-j])ats=min(ats, j*max(0LL,A[i]-j-skip));
        }
        cout<<ats<<"\n";
    }
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details