Codeforces 315C Sereja and Contest【思维】

C. Sereja and Contest
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.

Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula .

After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table.

We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants.

Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement.

Input

The first line contains two integers nk (1 ≤ n ≤ 2·105,  - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an(1 ≤ ai ≤ 109) — ratings of the participants in the initial table.

Output

Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table.

Examples
input
5 0
5 3 4 1 2
output
2
3
4
input
10 -10
5 5 1 7 5 1 2 4 9 2
output
2
4
5
7
8
9
Note

Consider the first test sample.

  1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first.
  2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place.
  3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place.
  4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered.

Thus, you should print 2, 3, 4.


题目大意:


给出一个长度为N的序列,以及一个常数K,我们每一次计算.

从左向右计算,直到第一个di<k为止,然后删除第i个数,从新计算。

输出过程中删除的数的位子。


思路:


我们知道,如果第一轮删除了a【i】,那么下一轮删除的数字的位子pos,一定是大于i的。

那么过程我们动态维护一下算式即可。

我们拆开Di=(j-1)*Σaj-(j-1)*(n-i)*ai;

那么我们前部分就是一个动态的前缀和,过程维护一下n的大小动态修改就行。


Ac代码:

#include<stdio.h>
#include<string.h>
using namespace std;
#define ll __int64
ll a[250000];
ll sum[250000];
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        sum[0]=0;
        for(int i=1;i<=n;i++)scanf("%I64d",&a[i]);
        ll bei=0;
        ll now=0;
        ll temp=n;
        for(int i=2;i<=n;i++)
        {
            now+=a[i-1]*bei;
            if(now-(temp-i+(n-temp))*a[i]*(i-1-(n-temp))<k)
            {
                temp--;
                now-=a[i]*bei;
                printf("%d\n",i);
            }
            else
            {
                bei++;
            }
        }
    }
}










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值