Cod sursa(job #2066506)

Utilizator alexpetrescuAlexandru Petrescu alexpetrescu Data 15 noiembrie 2017 03:44:10
Problema Nivele Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>

using namespace std;

ifstream fin("nivele.in");
ofstream fout("nivele.out");

#define MAXN 50000

int st[MAXN + 1];

int main() {
    int t;
    fin >> t;

    for (; t; t--) {
        int n;
        fin >> n;

        int vf = 0;
        for (; n; n--) {
            int x;
            fin >> x;

            st[++vf] = x;
            while (vf > 0 && st[vf] == st[vf - 1]) {
                vf--;
                st[vf]--;
            }
        }

        if (vf == 1) fout << "DA\n";
        else fout << "NU\n";
    }

    return 0;
}