General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
44595820 Contestant:
test616.cpp
1070J - 29 PyPy 2 Happy New Year! 1372 ms 7972 KB 2018-10-20 15:29:26 2018-10-20 15:29:26
 
 
→ Source
t=input()
for i in xrange(t):
	n, m, k=map(int, raw_input().split())
	cnt=[0]*26
	for ch in raw_input():
		cnt[ord(ch)-ord('A')]+=1
	assert sum(cnt)==k
	result=1000000000
	for common in xrange(26):
		dp=[False]*(n+1)
		dp[0]=True
		for cur in xrange(26):
			if cur!=common:
				cur=cnt[cur]
				for i in xrange(n, cur-1, -1):
					dp[i]=dp[i] or dp[i-cur]
		for i in xrange(max(n-cnt[common], 0), n+1):
			if dp[i]:
				result=min(result, (n-i)*max(m-(k-i-cnt[common]), 0))
				break
		for i in xrange(n, i, -1):
			if dp[i]:
				result=min(result, (n-i)*max(m-(k-i-cnt[common]), 0))
				break
	print result
	assert result<1000000000
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details