题解 CF570A 【Elections】

TRZ_2007

2019-08-15 21:16:29

Solution

## Remarks 看见大佬们用上了贪心,本蒟蒻深感不解。这题不就是一个模拟吗? ## Solution 首先这个题目有几个坑点,比如说,TA的读入是一个$m*n$的矩阵,而不是我们平时所想当然的$n*m$的矩阵(我被这里坑了2次)。 然后好像有一个数据的读入票数是负数,我Max定义成0被卡了。 剩下来就没有坑点了,直接贴代码吧。 ``` #include <bits/stdc++.h> using namespace std; const int N = 110; int x,id,city[N]; int n,m,Max; int main() { freopen("data.in","r",stdin); freopen("data.out","w",stdout); scanf("%d %d",&n,&m); for(int i=1;i<=m;i++) { Max = INT_MIN;id = 0; for(int j=1;j<=n;j++) { scanf("%d",&x); if(x > Max) { Max = x; id = j; } } city[id]++; } id = 0;Max = INT_MIN; for(int i=1;i<=n;i++) if(city[i] > Max) { Max = city[i]; id = i; } printf("%d\n",id); } ```