Cod sursa(job #148373)

Utilizator bogdanhm999Casu-Pop Bogdan bogdanhm999 Data 4 martie 2008 11:14:36
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <stdio.h>
#include <vector>

using namespace std;

vector <long>v;
long n,t,i,a,l,ok;

int main(){
    freopen("nivele.in","r",stdin);
    freopen("nivele.out","w",stdout);
    
    scanf("%ld",&t);
    for (;t;t--){
        scanf("%ld",&n);
        v.clear();l=-1;
        for (i=1;i<=n;i++){
            scanf("%ld",&a);
            v.push_back(a);
            l++;
            ok=1;
            while (ok){
                  ok=0;
                  if (l)
                     if (v[l-1]==v[l]){v[l-1]--;v.pop_back();l--;ok=1;}
            }
            
        }
        if (l==0&&v[0]==1)printf("DA\n");else printf("NU\n");
    }
    
return 0;
}