Cod sursa(job #3269657)
Utilizator | Data | 20 ianuarie 2025 11:15:01 | |
---|---|---|---|
Problema | Nivele | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <fstream>
#include <stack>
using namespace std;
ifstream in("nivele.in");
ofstream out("nivele.out");
int t, n;
int main()
{
in>>t;
while(t--)
{
stack<int> s;
in>>n;
int x;
for(int i = 1; i<=n; i++)
{
in>>x;
while(!s.empty() && s.top() == x)
{
s.pop();
x--;
}
s.push(x);
}
if(s.size() == 1 && s.top() == 1)
{
out<<"DA\n";
}
else
{
out<<"NU\n";
}
}
return 0;
}