General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
45900218 Practice:
xuyu070926
1070J - 29 GNU C++14 Accepted 124 ms 964 KB 2018-11-18 06:53:55 2018-11-18 06:53:55
 
 
→ Source
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2e5 + 10;
const int INF = 1e9 + 7;
int T, N, M, K;
char S[MAXN];
int A[26], f[MAXN];
int ans;

int main() {
	register int i, j, k;
	scanf("%d", &T);
	while(T--) {
		for(i = 0; i < 26; ++i)
			A[i] = 0;
		scanf("%d%d%d", &N, &M, &K);
		scanf("%s", S);
		for(i = 0; i < K; ++i)
			++A[S[i] - 'A'];
		ans = INF;
		for(i = 0; i < 26; ++i) {
			for(j = 0; j < N; ++j)
				f[j] = INF;
			f[N] = M;
			for(j = 0; j < 26; ++j) if(i != j)
				for(k = 0; k <= N; ++k) {
					f[k] = max(0, f[k] - A[j]);
					if(k + A[j] <= N) f[k] = min(f[k], f[k + A[j]]);
				}
			for(k = 0; k <= N; ++k)
				if(k + f[k] <= A[i])
					ans = min(ans, k * f[k]);
		}
		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