Pagini recente » Cod sursa (job #3340624) | Cod sursa (job #3246431) | Cod sursa (job #3320054) | Cod sursa (job #121308) | Cod sursa (job #1744647)
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream cin("nivele.in");
ofstream cout("nivele.out");
const int MAXN = 50000;
int Stack[1 + MAXN];
int main() {
int tests;
cin >> tests;
for (int test = 1; test <= tests; test++) {
int n;
cin >> n;
int top = 0;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
while (top > 0 && x == Stack[top] && x > 1) {
top--;
x--;
}
top++;
Stack[top] = x;
}
if (top == 1 && Stack[top] == 1)
cout << "DA\n";
else
cout << "NU\n";
}
return 0;
}