Cod sursa(job #2539087)

Utilizator PetyAlexandru Peticaru Pety Data 5 februarie 2020 16:45:07
Problema Nivele Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define f first
#define s second

ifstream fin ("nivele.in");
ofstream fout ("nivele.out");

int n, x;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  fin >> n;
  vector<int>v;
  for (int i = 1; i <= n; i++) {
    fin >> x;
    v.push_back(x);
    while (v.size() >= 2 && v[v.size() - 2] == v.back()) {
      v.pop_back();
      v.back()--;
    }
  }
  if (v.size() == 1 && v[0] == 1) {
    fout << "DA";
  }
  else
    fout << "NU";
  return 0;
}