Cod sursa(job #3282591)

Utilizator mihiboiBacis Mihai-Cristian mihiboi Data 6 martie 2025 09:40:50
Problema Nivele Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <bits/stdc++.h>
#define nmx 2005
#define sqr 317
using namespace std;
int t,n,x;
int main()
{
    ifstream f ("nivele.in");
    ofstream g ("nivele.out");
    f>>t;
    while (t--)
    {
        f>>n;
        deque <int> dq;
        for (int i=1; i<=n; i++)
        {
            f>>x;
            while (!dq.empty() && dq.front()==x)
            {
                dq.pop_front();
                x--;
            }
            dq.push_front(x);
        }
        if (dq.size()==1 && dq.front()==1)
            g<<"DA"<<'\n';
        else g<<"NU"<<'\n';
    }
}