# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087344 | vjudge1 | Izbori (COCI17_izbori) | C++17 | 1 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n, m, k;
cin >> n >> m >> k;
int a[n][m];
for(int i = 0;i < n; i++){
for(int j = 0;j < m ;j++){
cin >> a[i][j];
}
}
int cnt[16] = {};
pair<int, int>mx = {-1, -1};
for(int i = 0;i < n; i++){
cnt[a[i][0]]++;
mx = max(mx, make_pair(cnt[a[i][0]], a[i][0]));
}
cout << mx.second << endl;
int poi[n] = {}, ans = 0;
while(true){
for(int i = 0;i < 16; i++)cnt[i] = 0;
mx = {-1, -1};
for(int i = 0;i < n; i++){
cnt[a[i][poi[i]]]++;
mx = max(mx, make_pair(cnt[a[i][poi[i]]], a[i][poi[i]]));
}
if(mx.second == k)break;
for(int i = 0;i < n; i++){
if(poi[i]<m and mx.second==a[i][poi[i]] )poi[i]++;
}
ans++;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |