hiho week 86 register

Ended

Participants:360

Verdict:Accepted
Score:100 / 100
Submitted:2016-02-21 21:41:52

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
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=1010;
int n,k;
int a[maxn][maxn];
int main()
{
    while(cin>>n>>k){
        for(int i=0;i<n;i++)
            for(int j=0;j<k+1;j++){
                int x;
                scanf("%d",&x);
                a[i][x]=j;
            }
        int d=0;
        for(int i=k;i>0;i--){
            int s1=0,s2=0;
            for(int j=0;j<n;j++)
                if(a[j][i]<a[j][d]) s1++;
                else s2++;
            if(s1>s2) d=i;
        }
        if(d) printf("%d\n",d);
        else printf("otaku");
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX