#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m, k;
vector<int> prio[maxn];
int cnt[maxn];
int sol1() {
int mx=0,sol=1;
for(int i=1;i<=m;i++){
if(cnt[i]>mx){
mx=cnt[i];
sol=i;
}
}
return sol;
}
int main() {
cin >>n>>m>>k;
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++) {
int x;
cin >> x;
prio[i].push_back(x);
}
cnt[prio[i][0]]++;
}
cout << sol1() << endl;
int mn=m,off_cnt;
for(int mask = 0; mask < (1 << m); mask++) {
off_cnt = 0;
for(int i = 0; i < m; i++) {
cnt[i + 1] = 0;
if(mask & (1 << i)) {
off_cnt++;
}
}
off_cnt = m - off_cnt;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < m; j++) {
if(mask & (1 << (prio[i][j] - 1))) {
cnt[prio[i][j]]++;
break;
}
}
}
if(sol1()==k) {
mn = min(mn, off_cnt);
}
}
cout << mn << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
7 ms |
256 KB |
Output is correct |
12 |
Correct |
20 ms |
256 KB |
Output is correct |
13 |
Correct |
36 ms |
376 KB |
Output is correct |
14 |
Correct |
19 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
42 ms |
376 KB |
Output is correct |
17 |
Correct |
20 ms |
396 KB |
Output is correct |
18 |
Correct |
39 ms |
256 KB |
Output is correct |
19 |
Correct |
42 ms |
256 KB |
Output is correct |
20 |
Correct |
41 ms |
376 KB |
Output is correct |