Pagini recente » Cod sursa (job #1351318) | Cod sursa (job #1016295) | Cod sursa (job #2952098) | Cod sursa (job #1535668) | Cod sursa (job #2761736)
#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 = 0; i < N; i++){
cit>>v[i];
}
for(int i = N-1; i >= 0; i--){
refac_clasament(1, i, 0, N - 1, v[i]);
}
for(int i = 0; i < N; i++){
afis<<rez[i] + 1<<"\n";
}
return 0;
}