General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
47227977 Practice:
JioFell
1070J - 29 C++14 (GCC 6-32) Accepted 202 ms 516 KB 2018-12-18 19:59:29 2018-12-18 19:59:29
→ Source
#include<bits/stdc++.h>

using namespace std;

int cnt[26];

void work() {
    memset(cnt,0,sizeof cnt);
    int n, m, k;
    string s;
    cin >> n >> m >> k >> s;
    for(char c : s) cnt[c - 'A']++;
    int ans = n * m;
    for(int i = 0 ; i < 26 ; ++i)   {
        vector<bool> f(k - cnt[i] + 1,0);
        f[0] = 1;
        for(int j = 0 ; j < 26 ; ++j)   if (i != j)
        for(int l = k - cnt[i] ; l >= 0 ; --l)
            if (f[l])   f[l + cnt[j]] = 1;
        for(int j = 0 ; j <= k - cnt[i] ; ++j)  if (f[j])   {
            int x = max(0,n - j);
            int y = max(0,m + j + cnt[i] - k);
            if (x + y <= cnt[i])
                ans = min(ans,x * y);
        }
    }
    cout << ans << "\n";
}

int main()  {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int t;  cin >> t;
	
	while(t--)  work();
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details