Pagini recente » Cod sursa (job #2814128) | Cod sursa (job #1922509) | Cod sursa (job #835986) | Cod sursa (job #2927594) | Cod sursa (job #3148499)
#include <fstream>
using namespace std;
ifstream in ("nivele.in");
ofstream out ("nivele.out");
const int max_size = 5e4 + 1;
int stiva[max_size];
void solve ()
{
int n, vf = 0;
stiva[1] = 0;
in >> n;
while (n--)
{
int x;
in >> x;
stiva[++vf] = x;
while (vf > 1 && stiva[vf] == stiva[vf - 1])
{
stiva[--vf]--;
}
}
if (vf == 1 && stiva[vf] == 1)
{
out << "DA";
}
else
{
out << "NU";
}
out << '\n';
}
int main ()
{
int t;
in >> t;
while (t--)
{
solve();
}
in.close();
out.close();
return 0;
}