Cod sursa(job #461329)

Utilizator MKLOLDragos Ristache MKLOL Data 6 iunie 2010 13:29:29
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<stdio.h>

#define Nmax 101010

int stiv[Nmax],T,N,x;

int main()
{
    freopen("nivele.in","r",stdin);
    freopen("nivele.out","w",stdout);

    scanf("%d",&T);

    while(T--)
    {

    scanf("%d",&N);
    int vf=0;

    for(int i=1;i<=N;++i)
        {
        scanf("%d",&x);
            while(stiv[vf]==x&&vf>=1)
            {
                --vf;
                --x;
            }

        stiv[++vf]=x;
        }

        if(vf==1&&stiv[vf]==1)
            printf("DA\n");
            else printf("NU\n");

    }
}