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

题意:投票选州长  m个城市 n个候选人    给你n个候选人在每个城市的得票数   在当前城市获票最多的候选人获胜 当票数一样时 编号小的

候选人获胜  统计获得城市获胜最多的候选人作为州长  当出现获胜次数相同的情况下 输出编号最小的一名

题解: 水

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<algorithm>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
using namespace std;
int n,m;
int exm;
int biao;
map<int,int> mp;
int main()
{
int ans=;
int maaa=;
scanf("%d %d",&n,&m);
mp.clear();
for(int i=;i<=m;i++)
{
int biao=;
int maxn=-;
for(int j=;j<=n;j++)
{
scanf("%d",&exm);
if(exm>maxn)
{
maxn=exm;
biao=j;
}
}
mp[biao]++;
if(mp[biao]>maaa||(mp[biao]==maaa&&biao<ans))
{
maaa=mp[biao];
ans=biao;
}
}
cout<<ans<<endl;
return ;
}

Codeforces Round #316 (Div. 2) A 水的更多相关文章

  1. Codeforces Round #365 (Div. 2) A 水

    A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. Codeforces Codeforces Round #316 (Div. 2) C. Replacement set

    C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/proble ...

  3. Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树

    C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...

  4. Codeforces Round #316 (Div. 2)

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

  5. Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)

    A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:sta ...

  6. Codeforces Round #408 (Div. 2)(A.水,B,模拟)

    A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  7. Codeforces Round #394 (Div. 2)A水 B暴力 C暴力 D二分 E dfs

    A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #169 (Div. 2) A水 B C区间更新 D 思路

    A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #337 (Div. 2) A水

    A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...

随机推荐

  1. springmvc如何获取参数

    请参考这篇文章, 写得比较全面. https://www.cnblogs.com/xiaoxi/p/5695783.html

  2. CSS3和动画

    定位: z-index叠层    数字越大越往上层 注意:要用z-index属性必须设position属性 溢出:overflow 属性值:visible    不剪切内容也不添加滚动条 Auto   ...

  3. SpringBoot学习3:springboot整合filter

    整合方式一:通过注解扫描完成 Filter 组件的注册 1.编写filter package com.bjsxt.filter; import javax.servlet.*; import java ...

  4. 32-1题:不分行从上到下打印二叉树/BFS/deque/queue

    题目 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 考点 1.广度优先遍历 2.binary tree 3.queue 4.deque 思路 按层打印:8.6.10.5.7.9.11 用ST ...

  5. 转:maven国内镜像(maven下载慢的解决方法)

    http://www.cnblogs.com/xiongxx/p/6057558.html https://jingyan.baidu.com/article/1876c8524ee0d0890a13 ...

  6. HTML5/CSS3 第三章页面布局

    页面布局 1 页面组成 2 布局相关的标签 <div></div> 定义文档中的分区或节 <span></span> 这是一个行内元素,没有任何意义 & ...

  7. 19.VUE学习之- v-for与computed结合功能 筛选实例讲解

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 分享 php array_column 函数 无法在低版本支持的 修改

    function i_array_column($input, $columnKey, $indexKey=null){ if(!function_exists('array_column')){ $ ...

  9. utf8和utf8mb4区别

    原文链接 一.简介 MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode.好在utf8mb4是utf8的超集,除了将编 ...

  10. GIt-恢复进度

    继续暂存区未完成的实践 经过了前面的实践,现在DEMO版本库应该处于master分支上,看看是不是这样. $ cd /path/to/my/workspace/demo $ git status -s ...