|

General

# Author Problem Lang Verdict Time Memory Sent Judged
46975914 Practice:
vjudge5
1070J - 29 GNU C++11 Accepted 124 ms 1000 KB 2018-12-13 19:33:16 2018-12-13 19:33:16

→ Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;

const int N = 200010;
char s[N];
int dp[N];

void solve() {
int n, m, r;
scanf("%d%d%d", &n, &m, &r);
scanf("%s", s);
int cnt[26];
int ans = n * m;
memset(cnt, 0, sizeof(cnt));
for (int i = 0; s[i]; i++) cnt[s[i] - 'A']++;
for (int i = 0; i < 26; i++) {
for (int j = 0; j < n; j++) dp[j] = r + 1;
dp[n] = m;
for (int j = 0; j < 26; j++) {
if (i == j) continue;
for (int k = 0; k <= n; k++) {
dp[k] = max(0, dp[k] - cnt[j]);
if (k + cnt[j] <= n) dp[k] = min(dp[k], dp[k + cnt[j]]);
}
}

for (int j = 0; j <= n; j++)
if (j + dp[j] <= cnt[i]) ans = min(ans, j * dp[j]);
}
printf("%d\n", ans);
}

int main()
{
int t;
scanf("%d", &t);
while (t--) solve();
return 0;
}


?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details