Cod sursa(job #2555769)

Utilizator LivcristiTerebes Liviu Livcristi Data 24 februarie 2020 12:25:37
Problema Nivele Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
#define NUM 50005
using namespace std;
int stiv[NUM];
int t, n, top;
int main()
{
    ifstream f("nivele.in");
    ofstream g("nivele.out");
    f >> t;
    while(t > 0)
    {
        t--;
        f >> n;
        for(int i = 1; i <= n; ++i)
        {
            f >> stiv[++top];
            while(top > 1 && stiv[top] == stiv[top - 1])
                stiv[--top]--;
        }
        if(top == 1)
            g << "DA\n";
        else
            g << "NU\n";
    }
}