Cod sursa(job #3289549)
| Utilizator | Data | 27 martie 2025 13:26:38 | |
|---|---|---|---|
| Problema | Nivele | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.73 kb |
#include <fstream>
#include<unordered_map>
#include<stack>
using namespace std;
ifstream fin("nivele.in");
ofstream fout("nivele.out");
unordered_map<int,int>mp;
stack<int>st;
int main()
{
int t;
fin>>t;
while(t--)
{
int n,x,y;
fin>>n;
while(!st.empty())
st.pop();
for(int i=1;i<=n;i++)
{
fin>>x;
while(!st.empty()&&st.top()==x)
{
st.pop();
x--;
}
st.push(x);
}
if(st.top()==1&&st.size()==1)
{
fout<<"DA"<<"\n";
}
else
{
fout<<"NU"<<"\n";
}
}
return 0;
}
