Pagini recente » Cod sursa (job #2717693) | Cod sursa (job #1158247) | Cod sursa (job #1144386) | Cod sursa (job #1545508) | Cod sursa (job #2776459)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("nivele.in");
ofstream fout("nivele.out");
const int nmax = 50005;
int t, n, v[nmax], p;
int main(){
fin >> t;
while (t--){
fin >> n;
for (int i = 1; i <= n; ++i){
fin >> v[i];
}
stack <int> stiva;
stiva.push(v[1]);
for (int i = 2; i <= n; ++i){
int nv = v[i];
while (stiva.size() && nv == stiva.top()){
--nv;
stiva.pop();
}
stiva.push(nv);
}
if (stiva.size() == 1 && stiva.top() == 1){
cout << "DA\n";
}
else{
cout << "NU\n";
}
}
fin.close();
fout.close();
return 0;
}