#include #include #include using namespace std; const int N = 100000; int n, s, type[N]; int main() { int T; scanf("%d", &T); for (int t = 1; t <= T; t++) { scanf("%d %d", &n, &s); for (int i = 0; i < n; i++) scanf("%d", &type[i]); int cnt = 0; map freq; for (int i = 0; i < n; i++) { freq.clear(); int cur_cnt = 0; for (int j = i; j < n; j++) { if (freq.find(type[i]) == freq.end()) { freq[type[j]] = 1; cur_cnt++; } else { int f = freq[type[j]]; if (f < s) { cur_cnt++; } else if (f == s) { cur_cnt -= s; } freq[type[j]] = f + 1; } cnt = max(cnt, cur_cnt); } } printf("Case #%d: %d\n", t, cnt); } return 0; }