Cod sursa(job #2036275)
| Utilizator | Data | 10 octombrie 2017 16:05:55 | |
|---|---|---|---|
| Problema | Nivele | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include<cstdio>
using namespace std;
const int nmax=50005;
int st[nmax],top;
int main()
{
freopen("nivele.in","r",stdin);
freopen("nivele.out","w",stdout);
int i,j,n,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
top=0;
int x;
for(i=1;i<=n;++i)
{
scanf("%d",&x);
st[++top] = x;
while(top > 1 && st[top] == st[top-1])
{
st[--top]--;
}
}
if(st[top] == 1)
printf("DA\n");
else
printf("NU\n");
}
}
