Cod sursa(job #787482)

Utilizator danalex97Dan H Alexandru danalex97 Data 13 septembrie 2012 14:35:27
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
#include <vector>
using namespace std;

ifstream F("nivele.in");
ofstream G("nivele.out");

int T,N,A;
vector< int > V;

int main()
{
	F>>T;
	while ( T-- )
	{
		F>>N;
		while ( N-- )
		{
			F>>A;
			while ( V.size() && V.back()==A )
				V.pop_back(), --A;
			V.push_back( A );
		}
		if ( V.size()==1 && V.back()==1 ) 
			G<<"DA\n"; else G<<"NU\n";
		while ( V.size() ) 
			V.pop_back();
	}
}