Pagini recente » Cod sursa (job #1715810) | Cod sursa (job #1861193) | Cod sursa (job #2306144) | Cod sursa (job #2555865) | Cod sursa (job #2539470)
#include <cstdio>
using namespace std;
const int NMAX = 50005;
int st[NMAX];
int main() {
int T;
freopen("nivele.in", "r", stdin);
freopen("nivele.out", "w", stdout);
scanf("%d", &T);
while(T > 0) {
int n;
scanf("%d", &n);
int top = 0;
for(int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
st[++top] = x;
while(top >= 2 && st[top] == st[top - 1]) {
top--;
st[top]--;
}
}
if(top == 1 && st[top] == 1) {
printf("DA\n");
}
else {
printf("NU\n");
}
T--;
}
return 0;
}