codeforces-scrape

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

68B.md (1763B)


      1 Source: https://codeforces.com/problemset/problem/68/B
      2 
      3 B. Energy exchange
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the *i*-th accumulator has *a**i* units of energy. Energy can be transferred from one accumulator to the other. Every time *x* units of energy are transferred (*x* is not necessarily an integer) *k* percent of it is lost. That is, if *x* units were transferred from one accumulator to the other, amount of energy in the first one decreased by *x* units and in other increased by ![](https://espresso.codeforces.com/5da936c833914e398476bcdcd55a9583860c2e5c.png) units.
     22 
     23 Your task is to help Petya find what maximum equal amount of energy can be stored in each accumulator after the transfers.
     24 
     25 Input
     26 
     27 First line of the input contains two integers *n* and *k* (1 ≤ *n* ≤ 10000, 0 ≤ *k* ≤ 99) — number of accumulators and the percent of energy that is lost during transfers.
     28 
     29 Next line contains *n* integers *a*1, *a*2, ... , *a**n* — amounts of energy in the first, second, .., *n*-th accumulator respectively (0 ≤ *a**i* ≤ 1000, 1 ≤ *i* ≤ *n*).
     30 
     31 Output
     32 
     33 Output maximum possible amount of energy that can remain in each of accumulators after the transfers of energy.
     34 
     35 The absolute or relative error in the answer should not exceed 10- 6.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 3 50  
     43 4 2 1
     44 ```
     45 
     46 Output
     47 
     48 ```
     49 2.000000000
     50 ```
     51 
     52 Input
     53 
     54 ```
     55 2 90  
     56 1 11
     57 ```
     58 
     59 Output
     60 
     61 ```
     62 1.909090909
     63 ```