Cod sursa(job #926389)

Utilizator apopeid13Apopeid Alejandro apopeid13 Data 25 martie 2013 10:38:17
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>
  
using namespace std;
  
ifstream cin("nivele.in");
ofstream cout("nivele.out");
 
const char *mm[2] = {"NU","DA"};
const int nmax = int(5e4) + 2;
int T, N;
int st[nmax], K;
 
int main()
{
    int T;
    for(cin>>T;T;T--) {
        cin>>N;
        int lvl;
        K = 0;
        for(int i = 1;i <= N;i++) {
            cin>>lvl;
            st[++K] = lvl;
            while(K > 1 && st[K - 1] == st[K]) {
                st[K - 1]--;
                K--;
            }
             
        }
        cout<<mm[K == 1 && st[1] == 1]<<"\n";   
    }
    return 0;
}