Pagini recente » Cod sursa (job #1421947) | Cod sursa (job #26288) | Cod sursa (job #1186677) | Cod sursa (job #2365459) | Cod sursa (job #3156207)
#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) {
fout << "NU\n";
} else {
fout << "DA\n";
}
}
return 0;
}