Cod sursa(job #999322)

Utilizator rares96cheseliRares Cheseli rares96cheseli Data 19 septembrie 2013 21:43:40
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
using namespace std;
ifstream f("nivele.in");
ofstream g("nivele.out");

int t, n, st[50005];

int main()
{
    f>>t;
    while (t--)
    {
        f>>n; int top=0;
        for (int i=1; i<=n; ++i)
        {
            f>>st[++top];
            while (top>1 && st[top]==st[top-1])
                --top, --st[top];
        }
        if (top==1 && st[1]==1) g<<"DA\n";
            else g<<"NU\n";
    }
    return 0;
}