Cod sursa(job #982413)

Utilizator roots4Irimia Alexandru Gabriel roots4 Data 9 august 2013 11:12:57
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include<fstream>
#include<stack>

using namespace std;

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

stack<int> S;
int T , n , x ;

int main(){
	
	f>>T;
	
	while( T-- ){
		f>>n;
		
		for( int i = 1 ; i <= n ; i++ ){
			f>>x;
			
			while( S.empty() == 0 && S.top() == x ){
				x--;
				S.pop();
			}
			
			S.push(x);
		}
		
		if( S.size() == 1 && S.top() == 1 )
			g<<"DA";
		else
			g<<"NU";
		
		g<<"\n";
		
		while( !S.empty() )
			S.pop();
		
	}
	
	
	return 0;
}