Cod sursa(job #1046130)

Utilizator andreeaghetuUNIBUC andreeaghetu andreeaghetu Data 2 decembrie 2013 18:12:37
Problema Schi Scor 65
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("schi.in");
ofstream out ("schi.out");

int main()
{
    int x, N;
    in>>N;
    short int poz[N+1], v[N+1];
    for (int i=1;i<=N;++i)
    {
        in>>x;
        v[i]=x;
        poz[v[i]]=i;
        if (x!=i)
            for (int j=1;j<i;++j)
                if (v[j]>=x)
                {
                    ++v[j];
                    poz[v[j]]=j;
                }
    }
    for (int i=1;i<=N;++i)
        out<<poz[i]<<'\n';
    return 0;
}