Pagini recente » Cod sursa (job #741201) | Borderou de evaluare (job #1290433) | Borderou de evaluare (job #186988) | Borderou de evaluare (job #642014) | Cod sursa (job #2539459)
#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;
}