Cod sursa(job #1553697)

Utilizator daneel95Holteiu Daniel-Ninel daneel95 Data 20 decembrie 2015 12:50:54
Problema Schi Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb
#include <fstream>

using namespace std;

ifstream in("schi.in");
ofstream out("schi.out");

int n;
int final[30005];

int cautare(int x)
{
    if(final[x]!=0) return x;
    return 0;
}

int main()
{
    int i,j,nr=0,x,y;
    in>>n;
    //for(i=1;i<=n;i++) in>>partial[i];

    for(i=1;i<=n;i++)
    {
        in>>y;
        x=cautare(y);
        if(x)
        {
            for(j=nr;j>=x;j--)
                final[j+1]=final[j];
        }
        final[y]=i;
        nr++;
    }
    for(i=1;i<=n;i++) out<<final[i]<<"\n";
    in.close();
    out.close();
    return 0;
}