Submission #1308934

#TimeUsernameProblemLanguageResultExecution timeMemory
1308934rohit_flytsappIzbori (COCI17_izbori)C++20
48 / 80
1 ms348 KiB
#include<iostream> #include<algorithm> #include<vector> using namespace std; int find(vector<int> &arr, int x){ for(int i=0; i<arr.size(); i++) if(arr[i] == x) return i; return -1; } int main(){ int n, m, k; cin>>n>>m>>k; vector<vector<int>> pres(n, vector<int>(m)); for(auto &vec: pres){ for(auto &el: vec) cin>>el; } vector<int> votes(m+1, 0); for(int i=0; i<n; i++){ votes[pres[i][0]] ++; } int mx = 0, mxo = 0; for(int c=0; c<=m; c++){ if(mx < votes[c]){ mx = votes[c]; mxo = c; } } cout<<mxo<<"\n"; int winning = 0; int answer = 0; while(winning != k){ vector<int> votes(m+1, 0); for(int i=0; i<n; i++){ votes[pres[i][0]] ++; } int mx = 0, mxo = 0; for(int c=0; c<=m; c++){ if(mx < votes[c]){ mx = votes[c]; mxo = c; } } winning = mxo; if(winning == k) break; for(int i=0; i<n; i++){ int ind = find(pres[i], winning); pres[i].erase(pres[i].begin() + ind); } answer++; } cout<<answer<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...