Pagini recente » Cod sursa (job #496022) | Cod sursa (job #243861) | Cod sursa (job #651600) | Cod sursa (job #663502) | Cod sursa (job #2532027)
#include <fstream>
using namespace std;
ifstream cin("nivele.in");
ofstream cout("nivele.out");
const int N = 50000 + 7;
int n;
int stk[N];
int top;
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> n;
top = 0;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
stk[++top] = x;
while (top >= 2 && stk[top] == stk[top - 1])
{
top--;
stk[top]--;
}
}
if (top == 1 && stk[1] == 1)
{
cout << "DA\n";
}
else
{
cout << "NU\n";
}
}
}