Cod sursa(job #3297461)

Utilizator G3K0Airinei Gabriel Vlad G3K0 Data 22 mai 2025 17:20:29
Problema Schi Scor 65
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <bits/stdc++.h>


using namespace std;
ifstream f("schi.in");
ofstream g("schi.out");
void nos()
{
    ios_base::sync_with_stdio(false);
    f.tie(NULL);
}


int  main()
{
  nos();
  stack <int> aux;
  deque <int> ordine;
 //cout<<ordine.size();
  int n;
  f>>n;
  for(int i=1; i<=n; i++)
  {

      int poz;
      f>>poz;
      if(ordine.empty() || (!ordine.empty() and ordine.size()<poz))
        ordine.push_back(i);
        else
      {
          while(ordine.size()>=poz)
          {
              aux.push(ordine.back());
              ordine.pop_back();
          }
          ordine.push_back(i);
          while(!aux.empty())
          {
              ordine.push_back(aux.top());
              aux.pop();
          }

      }


  }
  while(!ordine.empty())
      {
          g<<ordine.front()<<'\n';
          ordine.pop_front();

      }

    return 0;
}