Cod sursa(job #1331905)
| Utilizator | Data | 1 februarie 2015 12:32:02 | |
|---|---|---|---|
| Problema | Schi | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | tabaraichb | Marime | 0.67 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] << " ";
fout << "\n";
return 0;
}
