PAT甲1054 The Dominant Color (20)(20 分)

#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N,M;

int main()
{
    int now=-1,num=1;
    scanf("%d%d",&N,&M);
    for(int i=0;i<M;i++)
    {
        for(int j=0;j<N;j++)
        {
            int a;
            scanf("%d",&a);
            if(a!=now)
            {
                num--;
                if(num==0)
                {
                    now=a;
                    num=1;
                }
            }
            else
            {
                num++;
            }
        }
    }
    printf("%d\n",now);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/yhy489275918/article/details/81877279