现在的位置: 首页 > 综合 > 正文

数学推公式——较难——Codeforces Round #187 (Div. 2)

2013年10月10日 ⁄ 综合 ⁄ 共 3504字 ⁄ 字号 评论关闭

题目链接:

http://codeforces.com/contest/315/problem/C

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.

Sample test(s)
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.

    分析:题目描述的公式,其结果分为两部分,一部分,只与没出局(d[i]>k)的有关,和当前的有关,且当前的公式部分不随出局人数的变化而变化。

    当前人d[i]<k时(也就是出局时),公式中的n要减一,当d[i]>k时,也就是当前人不出局时,合法人(li)要加一,前面的p(公式的与未出局的人有关的部分)要加上相应的数字部分。再细心点推公式。

    测试样例:

  5. 10 -40

    44

    108

    44

    40

    9

    94

    6

    59

    24

    102

     

    3 -40

    44

    6

    24

     

    4 -40

    44 6 24 102

  6. #include<iomanip>
    #include<iostream>
    #include<cstdio>
    using namespace std;
    #define ll long long
    ll a[920011];		//必须用long long。
    
    int main()
    {
          ll temp,cur,p,li;
    
          ll n,k,num;
          while(cin>>n>>k){
                for(int j=1;j<=n;j++)
    //                  scanf("%d", &a[j]);
                      cin>>a[j];
    
                p=0;
                cur=1;
                num=n;
                li=1;
    
                for(int j=1;j<n;j++){
                      temp = p +li*(li+1)*a[j+1] - num*li*a[j+1];
                      temp = p - (num - li - 1) * li * a[j+1];
                      //cout<<setw(8)<<right<<temp<<endl;
                      if(temp<k){
                            cout<<j+1<<endl;
                            num--;
                      }
                      else{
                            cur=j+1;
                            p=p+a[j+1]*li;
                            li++;
                      }
                }
    
    
                cout<<endl<<endl;
          }
    
          return 0;
    }
    

    抱歉!评论已关闭.