fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m;
  5. scanf("%d%d",&n,&m);
  6. int a[n+1];
  7. for(int i=0;i<n+1;i++)
  8. {
  9. a[i]=0;
  10. }
  11. int max=0;
  12. int cand;
  13. for(int i=0;i<m;i++)
  14. {
  15. for(int j=0;j<n;j++)
  16. {
  17. int votes;
  18. scanf("%d",&votes);
  19. if(votes>max)
  20. {
  21. max=votes;
  22. cand=j+1;
  23. }
  24. }
  25. a[cand]++;
  26. }
  27. int winner;
  28. max=0;
  29. for(int j=1;j<n+1;j++)
  30. {
  31. if(a[j]>max)
  32. {
  33. max=a[j];
  34. winner=j;
  35. }
  36. }
  37. printf("%d",winner);
  38. return 0;
  39.  
  40.  
  41. }
Success #stdin #stdout 0s 10304KB
stdin
3 3
1 2 3
2 3 1
1 2 1
stdout
3