Thứ Tư, 27 tháng 4, 2022

CARD679 C++

#include <bits/stdc++.h>
using namespace std;

int d[1000005];
int max1=-1,max0=-1,t,i,n;
void nhap()
{
    int x;
    scanf("%d\n",&n);
    for (i=1;i<=n/2;i++)
    {
        scanf("%d",&x);
        d[x]++;
    }
}
void tim_max1()
{
    t=0;max1=0;
    for(int i=1;i<=n;i++)
    {
        if(d[i]==1) t++;
        else t=0;
        if(t>max1) max1=t;
    }
}
void tim_max0()
{
    t=0;max0=0;
    for(int i=1;i<=n;i++)
    {
        if(d[i]==0) t++;
        else t=0;
        if(t>max0) max0=t;
    }
}

void xuli()
{
     tim_max1();
     tim_max0();
     if (max1>max0) cout<<"DUONG";
     else
        if (max1<max0) cout<<"TUNG";
         else
            if (d[n]==1) cout<<"DUONG";
             else  cout<<"TUNG";
}
int main()
{
    freopen("card679.inp","r",stdin);
    freopen("card679.out","w",stdout);
    nhap();
    xuli();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.