codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

379C.md (1434B)


      1 Source: https://codeforces.com/problemset/problem/379/C
      2 
      3 C. New Year Ratings Change
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 One very well-known internet resource site (let's call it X) has come up with a New Year adventure. Specifically, they decided to give ratings to all visitors.
     22 
     23 There are *n* users on the site, for each user we know the rating value he wants to get as a New Year Present. We know that user *i* wants to get at least *a**i* rating units as a present.
     24 
     25 The X site is administered by very creative and thrifty people. On the one hand, they want to give distinct ratings and on the other hand, the total sum of the ratings in the present must be as small as possible.
     26 
     27 Help site X cope with the challenging task of rating distribution. Find the optimal distribution.
     28 
     29 Input
     30 
     31 The first line contains integer *n* (1 ≤ *n* ≤ 3·105) — the number of users on the site. The next line contains integer sequence *a*1, *a*2, ..., *a**n* (1 ≤ *a**i* ≤ 109).
     32 
     33 Output
     34 
     35 Print a sequence of integers *b*1, *b*2, ..., *b**n*. Number *b**i* means that user *i* gets *b**i* of rating as a present. The printed sequence must meet the problem conditions.
     36 
     37 If there are multiple optimal solutions, print any of them.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 3  
     45 5 1 1
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 5 1 2
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 1  
     58 1000000000
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 1000000000
     65 ```