Cod sursa(job #783540)

Utilizator DaNutZ2UuUUBB Bora Dan DaNutZ2UuU Data 3 septembrie 2012 10:41:23
Problema Nivele Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include<fstream>
using namespace std;
ifstream fin("nivele.in");
ofstream fout("nivele.out");
long i,j,g,t,n;
long a[50010];

int main()
{
	fin>>t;
	
	for (g=0;g<t;g++)
	{
		fin>>n;
		for (i=1, j=1;i<=n;i++, j++)
		{
			fin>>a[j];
			while (a[j]==a[j-1])
			{
				a[j-1]=a[j]-1;
				a[j]=0;
				j--;
			}
		}
		j--;
		if (j==1 && a[j]==1)
			fout<<"DA"<<"\n";
		fout<<"NU"<<"\n";
	}
	fout.close();
	fin.close();
	return 0;
}