A:Elections
The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.
The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each city won the candidate who got the highest number of votes in this city, and if several candidates got the maximum number of votes, then the winner is the one with a smaller index.
At the second stage of elections the winner is determined by the same principle over the cities: the winner of the elections is the candidate who won in the maximum number of cities, and among those who got the maximum number of cities the winner is the one with a smaller index.
Determine who will win the elections.
Input
The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively.
Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 10^9) denotes the number of votes for candidate j in city i.
It is guaranteed that the total number of people in all the cities does not exceed 10^9.
Output
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
Examples
Input
3 3
1 2 3
2 3 1
1 2 1
Output
2
Input
3 4
10 10 3
5 1 6
2 2 2
1 5 7
Output
1
题意: n个候选人m个城市,第一阶段每个城市内最高票数者得分;第二阶段选出累计得分最高的人。(同分则下标小为ans)
#include <bits/stdc++.h>
using namespace std;
int n,m,cnt[110];
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int x,k=1,INF=-1;
for(int j=1;j<=n;j++)
{
cin>>x;
if(INF<x) INF=x,k=j