Pagini recente » Cod sursa (job #3175268) | Cod sursa (job #2582730) | Cod sursa (job #3198926) | Cod sursa (job #2820810) | Cod sursa (job #2761737)
#include<iostream>
#include<fstream>
using namespace std;
ifstream cit("schi.in");
ofstream afis("schi.out");
int N, v[30001], rez[30001], temp[60001];
void refac_clasament(int poz, int prez, int st, int dr, int nr){
int mij;
if(st == dr){
temp[poz] = 1;
rez[st] = prez;
return;
}
mij = (st + dr)/2;
if(nr <= mij - st + 1 - temp[2 * poz]){
refac_clasament(2 * poz, prez, st, mij, nr);
}
else{
refac_clasament(2 * poz + 1, prez, mij + 1, dr, nr - mij + st - 1 + temp[2 * poz]);
}
temp[poz] = temp[2 * poz] + temp[2 * poz + 1];
}
int main()
{
cit>>N;
for(int i = 1; i <= N; i++){
cit>>v[i];
}
for(int i = N; i >= 1; i--){
refac_clasament(1, i, 1, N, v[i]);
}
for(int i = 1; i <= N; i++){
afis<<rez[i]<<"\n";
}
return 0;
}