Cod sursa(job #2761143)

Utilizator VladCaloVlad Calomfirescu VladCalo Data 30 iunie 2021 20:49:23
Problema Schi Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.72 kb
//
//  main.cpp
//  schi
//
//  Created by Vlad Calomfirescu on 14.05.2021.
//

#include <iostream>
#include <fstream>
#include <vector>
 
using namespace std;
ifstream fin("schi.in");
ofstream fout("schi.out");
 
//int n, m, val, pos, rez;
//int v[30002],sol[30002], a[4 * 30002];
//
//
//void update(int nod, int stg, int dr)
//{
//    if (stg == dr)
//    {
//        a[nod] = val;
//        return;
//    }
//    int mij = (stg + dr) / 2;
//    if (pos <= mij)
//        update(2 * nod, stg, mij);
//    else
//        update(2 * nod + 1, mij + 1, dr);
//    a[nod] = a[2*nod]+a[2*nod+1];
//}
//
//void qr(int nod, int stg, int dr)
//{
//    if (stg==dr)
//    {
//        rez = stg;
//        return;
//    }
//    int mij = (stg + dr) / 2;
//    if (a[2 * nod] >= val)
//        qr(2 * nod, stg, mij);
//    else
//    {
//        val = val - a[2 * nod];
//        qr(2 * nod + 1, mij + 1, dr);
//    }
//}
//
//int main()
//{
//    fin >> n;
//    for (int i = 1; i <= n; i++)
//    {
//        fin >> v[i];
//        pos = i;
//        val = 1;
//        update(1, 1, n);
//    }
//    for (int i = n; i >= 1; i--)
//    {
//        rez = 0;
//        val = v[i];
//        qr(1, 1, n);
//        sol[rez] = i;
//        pos = rez;
//        val = 0;
//        update(1, 1, n);
//    }
//    for (int i = 1; i <= n; i++)
//        fout << sol[i] << "\n";
//
//    return 0;
//}



int n;

vector <int> :: iterator it ;

int main(){
    vector <int > v;
    fin >>n;
    
    for (int i=1;i<=n;i++)
    {
        int x;
        fin>>x;
        it=v.begin();
        v.insert (it + x -1 , i); // este -1 pt ca altfel incerca sa insereze la poz 1 direct
    
    }

    for (int i=0; i< v.size();i++)
    {
        fout<< v[i]<<" ";
    }
    
    return 0;
}