Cod sursa(job #2558091)

Utilizator vladsfStirbu Vlad Florin vladsf Data 26 februarie 2020 11:56:00
Problema Nivele Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>

using namespace std;

ifstream f("nivele.in");
ofstream g("nivele.out");

// Seria borderlands e cea mai naspa din toata istoria gaming-ului, can't change my mind

int steve[50001];

int main()
{
    int ciururi;
    f>>ciururi;
    while (ciururi--)
    {
        int top=0,n,x,y;
        f>>n;
        f>>x;
        steve[++top]=x;
        for (int i=2; i<=n; i++)
        {
            f>>y;
            steve[++top]=y;
            while (top>1 && steve[top]==steve[top-1])
            {
                steve[--top]-=1;
            }
            x=y;

        }
        (steve[top] == 1 && top == 1) ? g<<"DA" : g<<"NU";
        g<<'\n';
    }
    return 0;
}