#include #include #include #include #include #include int a[60010]; const int maxn = 2e5+6; int lowbit[maxn],tree[maxn]; int ans[60010]; void GetLowbit() { for(int i=1;i0;i-=lowbit[i]) ret+=tree[i]; return ret; } int Find(int x,int n) { int ret=1e9,down=1,mid,up=n,v; while(down<=up) { mid=(down+up)>>1; v=query(mid); if(v>=x) { up=mid-1; if(mid=0;i--) { if(i>=1)t=a[i]-a[i-1]; else t=a[i]; //printf("%d %d %d\n ",t+1, tmp+1-(t+1),Find(tmp+1-(t+1),n)); //system("pause"); ans[i] = Find(tmp+1-(t+1),n); tmp--; update(ans[i],-1); } printf("%d",ans[0]); for(i=1;i<=n-1;i++) printf(" %d",ans[i]); printf("\n"); } return 0; }