Submission #176063

#TimeUsernameProblemLanguageResultExecution timeMemory
176063bkosmacinIzbori (COCI17_izbori)C++14
80 / 80
42 ms396 KiB
#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 timeMemoryGrader output
Fetching results...