Cod sursa(job #525668)

Utilizator antoanelaAntoanela Siminiuc antoanela Data 25 ianuarie 2011 20:00:51
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <cstdio>

int main()
{
	freopen("nivele.in","r",stdin);
	freopen("nivele.out","w",stdout);
	int t, n, i, h, v[50010], x;
	scanf("%d",&t);
	while (t--)
	{
		scanf("%d",&n);
		h=0;
		for (i=1; i<=n; i++)
		{
			scanf("%d",&x);
			h++;
			v[h]=x;
			while (h>1 && v[h]==v[h-1]) v[--h]--;
		}
		if (h==1 && v[1]==1) printf("DA\n"); else printf("NU\n");
	}
}