# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
176063 | bkosmacin | Izbori (COCI17_izbori) | C++14 | 42 ms | 396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|---|---|---|---|
Fetching results... |