Pagini recente » Cod sursa (job #321029) | Cod sursa (job #155893) | Cod sursa (job #1156039) | Cod sursa (job #963572) | Cod sursa (job #1440659)
#include<cstdio>
#include<set>
using namespace std;
set<int> v;
set<int>::iterator it,it1;
int i,j,n,vc[30001],vec[30001],q;
int main ()
{
freopen("schi.in","r",stdin);
freopen("schi.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&vc[i]);
for(i=n;i>=1;i--)
{
q=0;
it1=v.upper_bound(vc[i]);
set<int>::iterator it2;
it2=v.begin();
q=it1-it2;
int pp=0;
while(pp==0)
{
it=v.upper_bound(vc[i]+q);
vc[i]+=q;
q=it1-it;
if(q==0)
{
pp=1;
vec[i]=vc[i];
}
it1=it;
}
v.insert(vc[i]);
}
for(i=1;i<=n;i++)
vc[vec[i]]=i;
for(i=1;i<=n;i++)
printf("%d\n",vc[i]);
return 0;
}