A. Elections-----------(Codeforces Round #316 (Div. 2))

本文概述了AI音视频处理领域的关键技术,包括视频分割、语义识别、自动驾驶、AR、SLAM、物体检测与识别、语音识别变声等,为读者提供了全面的技术视角。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Elections
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 nm (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 ≤ n1 ≤ i ≤ m0 ≤ aij ≤ 109) 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 109.

Output

Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.

Sample test(s)
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
Note

Note to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.

Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a smaller index, so the city chose candidate 1. City 2 chosen candidate 3. City 3 chosen candidate 1, due to the fact that everyone has the same number of votes, and 1 has the smallest index. City 4 chosen the candidate 3. On the second stage the same number of cities chose candidates 1 and 3. The winner is candidate 1, the one with the smaller index.



第一次打Codeforces比赛,从12:30开始,3:30多才睡,等了40多分钟的成绩,还不错。AC了3道,涨了152分。

分析:最值处理问题吧,每行比较大小,选出最大值的下标,输出下标出现最多的下标值。


CODE:

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,a[105];
    while(cin>>n>>m){
        int ans[105];
        memset(ans,0,sizeof(ans));
        for(int i=0;i<m;i++){
            cin>>a[0];
            int MAXnum=a[0];
            int MAXpeo=1;
            for(int j=1;j<n;j++){
                cin>>a[j];
                if(a[j]>MAXnum){
                    MAXnum=a[j];
                    MAXpeo=j+1;
                }
            }
            ans[MAXpeo]++;
        }
        int ret=0,tmp=-100;
        for(int i=1;i<=n;i++){
            if(ans[i]>tmp){
                tmp=ans[i];
                ret=i;
            }
        }
        cout<<ret<<endl;
    }
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值