General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
82563989 Practice:
np_compete007
1070J - 29 C++17 (GCC 9-64) Accepted 280 ms 732 KB 2020-06-04 20:40:16 2020-06-04 21:07:10
→ Source
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

main()
{
	int t;
	cin>>t;
	
	while(t--)
	{
		int n,m,l;
		cin>>n>>m>>l;
		
		string s;
		cin>>s;
		
		vector<int> v(26);
		
		for(auto i:s)
		v[i-'A']++;
		
		ll ans=1e9;
		
		for(int i=0;i<26;i++)
		{
			vector<ll> dp(n+1,1e9);
			dp[n]=m;
			
			for(int j=0;j<26;j++)
			{
				if(i!=j)
				{
					for(int k=0;k<=n;k++)
					{
						dp[k]=max(0LL,dp[k]-v[j]);
						
						if(k+v[j]<=n)
						{
							dp[k]=min(dp[k],dp[k+v[j]]);
						}
					}
				}
			}
			
			for(int j=0;j<=n;j++)
			{
				if(j+dp[j]<=v[i])
				ans=min(ans,j*dp[j]);
			}
		}
		
		cout<<ans<<endl;
	}
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details