Pagini recente » Cod sursa (job #524560) | Cod sursa (job #161202) | Cod sursa (job #1081695) | Cod sursa (job #189557) | Cod sursa (job #1809579)
#include <bits/stdc++.h>
using namespace std;
#ifdef INFOARENA
#define cout fout
#endif // INFOARENA
ifstream fin("schi.in");
ofstream fout("schi.out");
#define nmax 30001
int n,m;
int aib[nmax];
int loc[nmax],loc_fin[nmax];
void update(int pos,int val)
{
for(; pos<=n; pos+=(pos&-pos)) aib[pos]+=val;
}
int query(int pos)
{
int res=0;
for(; pos; pos-=(pos&-pos)) res+=aib[pos];
return res;
}
int binsrc(int val)
{
int step,pos=0;
for(step=1; step<=n; step<<=1);
for(step>>=1; step; step>>=1)
{
if(pos+step<=n)
if(aib[pos+step]<=val)
{
pos+=step;
val-=aib[pos];
}
}
return pos;
}
void read()
{
fin>>n;
for(int i=1; i<=n; ++i) fin>>loc[i];
}
int main()
{
read();
int i,x;
for(i=1; i<=n; ++i)
update(i,1);
for(i=n; i; --i)
{
x=binsrc(loc[i]-1)+1;
loc_fin[x]=i;
update(x,-1);
}
for(i=1;i<=n;++i) cout<<loc_fin[i]<<'\n';
return 0;
}