A10053 | Elections
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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}<=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}$ .
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}<=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}$ .
输出格式
Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted