hiho week 86 register

Ended

Participants:360

Verdict:Accepted
Score:100 / 100
Submitted:2016-02-22 16:42:26

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>
#include <cstring>
#include <cstdio>
#define lowbit(x) (x&(-x))
using namespace std;
 
int map[1005][1005];
 
int n,k,t;
 
int main(){
 
    while(scanf("%d%d",&n,&k)!=EOF){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=k+1;j++){
                scanf("%d",&t);
                map[i][t]=j;
            }
        }
        int ans=0;
        for(int j=k;j>=1;j--){
            int cnt=0;
            for(int i=1;i<=n;i++){
                if(map[i][j]<map[i][ans])
                cnt++;
            }
            if(cnt>n/2)
            ans=j;
        }
        if(ans>0)
        printf("%d\n",ans);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX