Pagini recente » Cod sursa (job #359935) | Cod sursa (job #694827) | Cod sursa (job #2098362) | Cod sursa (job #1069083) | Cod sursa (job #3165968)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("nivele.in");
ofstream fout("nivele.out");
const int NMAX = 50003;
int st[NMAX], top;
int main() {
int t;
fin >> t;
while (t--) {
int n;
fin >> n;
top = 0;
for (int i = 1; i <= n; i++) {
int x;
fin >> x;
while (top > 0 && x == st[top]) {
x--;
top--;
}
st[++top] = x;
}
if (top > 1 || st[top] != 1) {
fout << "NU\n";
} else {
fout << "DA\n";
}
}
return 0;
}