Mathematical formula -- difficulty -- codeforces round #187 (Div. 2)

Source: Internet
Author: User

Question link:

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

C. sereja and contesttime 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 stored times, so the round was decided to be made unrated for some participant.

Let's assume thatNPeople took part in the contest. Let's assume that the participant who got the first place has ratingA1,
The second place maidA2 ,...,
TheN-Th place maid has ratingAN.
Then changing the rating on the codesecrof site is calculated by the formula.

After the round was over, the codesecrof Management published the participates in the results table. They decided that if for a participantDILatency <latencyK,
Then the round can be considered unrated for him. but imagine the management's surprise when they found out that the participant 'rating table is dynamic. in other words, when some particle ant 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 whoDILatency <latencyK.
We also know that the applications for exclusion from rating were submitted by all participant.

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

Input

The first line contains two integersN,K(1 digit ≤ DigitNLimit ≤ limit 2 · 105, maximum cost-limit 109 limit ≤ limitKLimit ≤ limit 0 ).
The second line containsNSpace-separated IntegersA1, bytes,A2, middle..., middle ,...,AN(1 digit ≤ DigitAILimit ≤ limit 109 )-
Ratings of the maid in the initial table.

Output

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

Sample test (s) Input
5 05 3 4 1 2
Output
234
Input
10 -105 5 1 7 5 1 2 4 9 2
Output
245789
Note

Consider the first test sample.

  1. Initially the sequence of the contest participant ipants '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
    Second place will be considered first.

  2. As soon as the second place winner is out from the ratings, the participant '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
    Particle ant who won the second place will be considered. Initially this particle ant 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 maid's application is taken into consideration, initially this particle ant 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 shoshould print 2, 3, 4.

    Analysis:The results of the formula described in the question are divided into two parts, one of which is only related to the absence of (d [I]> K) and the current one, the current formula does not change with the number of outgoing users.

    When the current user d [I] <k hour (that is, when the user is out), the N in the formula must be reduced by one. When d [I]> K, that is, when the current user is not out, the legal person (LI) needs to add one, and the previous P (the part of the formula related to the person not going out) needs to add the corresponding numerical part. Then, let's take a closer look at the formula.

    Test example:

  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 longll A [920011]; // long is required. 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;} return 0 ;}

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.