codeforces D. Restore Permutation

An array of integers p 1 ,p 2 ,…,p n
p1,p2,…,pn
is called a permutation if it contains each number from 1
1
to n
n
exactly once. For example, the following arrays are permutations: [3,1,2],[1],[1,2,3,4,5]
[3,1,2],[1],[1,2,3,4,5]
and [4,3,1,2]
[4,3,1,2]
. The following arrays are not permutations: [2],[1,1],[2,3,4]
[2],[1,1],[2,3,4]
.

There is a hidden permutation of length n
n
.

For each index i
i
, you are given s i
si
, which equals to the sum of all p j
pj
such that j<i
j<i
and p j <p i
pj<pi
. In other words, s i
si
is the sum of elements before the i
i
-th element that are smaller than the i
i
-th element.

Your task is to restore the permutation.

这个的题意就是给你一个s数组 si表示就是第i个数前面比它小的数的和为多少
这个的思路就是从最后一个开始考虑 因为可以很容易的求出最后一位是多少
然后把最后以为的影响消除掉
可以知道最后一位

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值