日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 570A】Elections(模拟,水题)

發(fā)布時(shí)間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 570A】Elections(模拟,水题) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

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?≤?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.

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

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.

題目大意:

? ? 有n個(gè)候選人和m個(gè)城市,現(xiàn)在要從m個(gè)城市中的選票中選取得票最高的候選人,如果在一個(gè)城市中兩個(gè)候選人得到的票數(shù)是相同的且是最高的,那么標(biāo)號(hào)小的候選人獲勝,如果m個(gè)城市中選出的候選人的中有票數(shù)最高且相同的,依舊選標(biāo)號(hào)最小的。

解題報(bào)告:

? ? 按照題意模擬就可以了。

AC代碼:

#include<bits/stdc++.h> #define ll long long using namespace std;ll maze[105][105],num[105]; int main() {int n,m;cin>>m>>n; for(int i = 1; i<=n; i++) {for(int j = 1; j<=m; j++) {scanf("%lld",&maze[i][j]);}}int maxi=1;for(int i = 1; i<=n; i++) {maxi=1;for(int j = 1; j<=m; j++) {if(maze[i][j]>maze[i][maxi]) maxi=j;}num[maxi]++;}int ans = 1;for(int i = 1; i<=m; ++i) {if(num[i]>num[ans]) ans=i;}printf("%d\n",ans);return 0; }

?

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 570A】Elections(模拟,水题)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。