hiho week 86 register

Ended

Participants:360

Verdict:Accepted
Score:100 / 100
Submitted:2016-02-27 16:16:04

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 <bits/stdc++.h>
int rank[1100][1100];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            int x;
            scanf("%d",&x);
            rank[i][x] = j;
        }
    }
    int result = 0;
    for(int i = m; i >= 1; i--)
    {
        int vote = 0;
        for(int j = 1; j <= n; j++)
        {
            if(rank[j][i] < rank[j][result])
                vote++;
        }
        if(vote > n / 2) result = i;
    }
    if(result)
        printf("%d\n",result);
    else printf("otaku\n");
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX