Cod sursa(job #782526)
| Utilizator | Data | 28 august 2012 11:02:59 | |
|---|---|---|---|
| Problema | Nivele | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.67 kb |
# include <cstdio>
# include <stack>
using namespace std;
int n, t, i, j, a;
int main()
{
stack<int>S;
freopen("nivele.in","r",stdin);
freopen("nivele.out","w",stdout);
scanf("%d",&t);
for (i = 1; i <= t; i++)
{
scanf("%d",&n);
for (j = 1; j <= n; j++)
{
scanf("%d",&a);
while (!S.empty() && S.top() == a)
{
S.pop();
a--;
}
S.push(a);
}
if (S.size() == 1 && S.top() == 1)
printf("DA");
else printf("NU");
}
}
