CF570A.Elections
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
拜莱钦斯克国正在举行一场涉及 n 名候选人的选举。该国由 m 座城市组成。我们已知每座城市中每位候选人获得的票数。
该国的选举制度非常特殊。在选举的第一阶段,对每座城市分别统计选票:假设每座城市中得票数最高的候选人获胜;若多名候选人得票数并列最高,则编号较小者获胜。
在选举的第二阶段,按相同原则在城市层面进行统计:最终胜出的候选人是赢得城市数量最多的那位;若多名候选人赢得的城市数量并列最多,则编号较小者获胜。
请确定本次选举的获胜者。
输入格式
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 a__ij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ a__ij ≤ 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.
输入的第一行包含两个整数 n、m(1≤n,m≤100),分别表示候选人数量和城市数量。
接下来的 m 行,每行包含 n 个非负整数;其中第 i 行的第 j 个数 aij(1≤j≤n,1≤i≤m,0≤aij≤109)表示第 i 个城市中候选人 j 获得的票数。
保证所有城市的总人口数不超过 109。
输出格式
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
输出一个数字——赢得选举的候选人的编号。候选人编号从 1 开始。
输入输出样例
输入#1
3 3 1 2 3 2 3 1 1 2 1
输出#1
2
输入#2
3 4 10 10 3 5 1 6 2 2 2 1 5 7
输出#2
1
说明/提示
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.
第一个样例测试说明:在第一轮中,城市 1 选择候选人 3,城市 2 选择候选人 2,城市 3 选择候选人 2。获胜者为候选人 2,他获得了 2 票。
第二个样例测试说明:在第一轮中,城市 1 中候选人 1 和 2 获得了相同的最高票数,但候选人 1 的编号更小,因此该城市选择候选人 1;城市 2 选择候选人 3;城市 3 中所有候选人得票数相同,而候选人 1 编号最小,因此该城市选择候选人 1;城市 4 选择候选人 3。在第二轮中,选择候选人 1 和候选人 3 的城市数量相同。获胜者为编号更小的候选人 1。
输入解题思路,AI测评打分。不知道怎么写?