Cod sursa(job #2539478)
Utilizator | Data | 5 februarie 2020 21:34:10 | |
---|---|---|---|
Problema | Nivele | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <fstream>
using namespace std;
const int NMAX = 50005;
int st[NMAX];
int main() {
int T, n, x;
ifstream cin("nivele.in");
ofstream cout("nivele.out");
cin >> T;
while(T > 0) {
cin >> n;
int top = 0;
for(int i = 1; i <= n; i++) {
cin >> x;
st[++top] = x;
while(top > 1 && st[top] == st[top - 1]) {
st[--top]--;
}
}
if(top == 1 && st[top] == 1) {
cout << "DA\n";
}
else {
cout << "NU\n";
}
T--;
}
return 0;
}