#include <bits/stdc++.h>
#define int long long
using namespace std;
pair<int, int> it[500000], lazy[500005];
int a[100005], ans[100005];
int sum[100005];
int n;
void build_tree(int id, int l, int r)
{
if(l==r)
{
// cout<<a[l]-sum[l-1]<<" "<<l<<endl;
it[id]={a[l]-sum[l-1], l};
return;
}
int mid=(l+r)/2;
build_tree(id*2, l, mid);
build_tree(id*2+1, mid+1, r);
it[id]=max(it[id*2], it[id*2+1]);
}
void down(int id)
{
it[id*2].first+=lazy[id].first;
lazy[id*2].first+=lazy[id].first;
it[id*2+1].first+=lazy[id].first;
lazy[id*2+1].first+=lazy[id].first;
lazy[id].first=0;
}
void update(int id, int l, int r, int u, int v, int val)
{
if(l>v||r<u) return;
if(l>=u&&r<=v)
{
it[id].first+=val;
lazy[id].first+=val;
return;
}
down(id);
int mid=(r+l)/2;
update(id*2, l, mid, u, v, val);
update(id*2+1, mid+1, r, u, v, val);
it[id]=max(it[id*2], it[id*2+1]);
}
signed main()
{
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>a[i];
a[i]-=sum[i-1];
sum[i]=sum[i-1]+a[i];
}
build_tree(1, 1, n);
for(int i=n; i>=1; i--)
{
int omg=it[1].second;
assert(ans[omg]==0);
ans[omg]=i;
update(1, 1, n, omg, omg, -34278196123467);
update(1, 1, n, omg, n, a[omg]);
}
for(int i=1; i<=n; i++)
{
cout<<ans[i]<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |