Cod sursa(job #1331906)

Utilizator thehuntestshadowDragomir Alexandru thehuntestshadow Data 1 februarie 2015 12:33:13
Problema Schi Scor 70
Compilator cpp Status done
Runda tabaraichb Marime 0.66 kb
#include <iostream>
#include<fstream>
using namespace std;
#define NMAX 30022
int order[NMAX];

int main()
{
    ifstream fin ("schi.in");

    int n;
    fin >> n;
    int x;
        int last=1;
    for(int i=1;i<=n;++i)
    {fin >> x;
        if(order[x]>0){last=0;
        for(int k=1;k<=n;++k){
                if(order[k]==0)
                break;
                last=k;}
            for(int j=last+1;j>x;--j)
            {
                order[j]=order[j-1];
            }order[x]=i;}
        else order[x]=i;

    }

    ofstream fout ("schi.out");
    for(int i=1;i<=n;++i)
        fout << order[i] << "\n";

    return 0;
}