hiho week 86 register

Ended

Participants:360

Verdict:Accepted
Score:100 / 100
Submitted:2016-02-23 11:36:10

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
const int N = 1000;
int n,k,vot[N][N];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= k; j++) {
            int x; cin >> x;
            vot[i][x] = j;
        }
    }
    
    int res = 0;
    for(int j = k; j >= 1; j--) {
        int v = 0;
        for(int i = 0; i < n; i++) {
            if(vot[i][j] <= vot[i][res]) v++;
        }
        //cout << "vot="<< v << endl;
        if(v*2 > n) {
            res = j;
        }
    }
    
    if(res==0) cout << "otaku" <<endl;
    else cout << res << endl;
    
    return 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX