Cod sursa(job #2944319)

Utilizator alexboat10759Alex Mateescu alexboat10759 Data 22 noiembrie 2022 12:44:17
Problema Schi Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v;
int poz[30005];

struct mama
{
    int val, poz;
};

mama rez[30005];

bool cmp(mama a, mama b)
{
    return a.val < b.val;
}

int main()
{
    ifstream cin("schi.in");
    ofstream cout("schi.out");

    int n;
    cin>>n;

    v.push_back(0);
    for(int i = 1; i <= n; i++)
    {
        cin>>poz[i];
        v.push_back(i);
    }

    for(int i = n; i >= 1; i--)
    {
        rez[i].val = v[poz[i]];
        rez[i].poz = i;
        v.erase(v.begin() + poz[i]);
    }
    sort(rez + 1, rez + n + 1, cmp);
    for(int i = 1; i <= n; i++)
        cout<<rez[i].poz<<'\n';

    return 0;
}