Cod sursa(job #1852306)
| Utilizator | Data | 20 ianuarie 2017 18:00:45 | |
|---|---|---|---|
| Problema | Nivele | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("nivele.in");
ofstream g("nivele.out");
int t,n,start,nr,noduri,x;
int main()
{
f >> t;
while(t--){
f >> n;
stack<int> s;
for(int i = 1; i <= n; ++i){
f >> x;
while(!s.empty() && x == s.top() && x > 1){
s.pop();
x--;
}
s.push(x);
}
if(s.top() == 1){
g << "DA" << '\n';
}else{
g << "NU" << '\n';
}
}
return 0;
}
