PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000415. Cân bằng lượng nước giữa các thùng (Pour Water Between Buckets to Make Water Levels Equal)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cân bằng lượng nước giữa các thùng (Pour Water Between Buckets to Make Water Levels Equal)

Pour Water Between Buckets to Make Water Levels Equal

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn buckets numbered 1 through nn. Bucket ii initially holds aia_i gallons. You may transfer any amount of water, including a noninteger amount, between two distinct buckets, provided the source has enough water. A transfer of uu gallons loses Lu/100Lu/100 gallons; the destination receives the rest. Equalize all bucket amounts and maximize their common amount.

Input

The first line contains integers n,Ln,L, the bucket count and percentage loss. The second line contains nn integers a1,…,ana_1,\ldots,a_n, the initial water amounts in gallons.

Output

Print the maximum common amount in gallons. Absolute error must not exceed 10−510^{-5}.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10001\le n\le 1000; 0≤ai≤1050\le a_i\le10^5 for every 1≤i≤n1\le i\le n; L=0L=0.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; 0≤ai≤1050\le a_i\le10^5 for every 1≤i≤n1\le i\le n; 0≤L≤990\le L\le99.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 0≤ai≤1050\le a_i\le10^5 for every 1≤i≤n1\le i\le n; 0≤L≤990\le L\le99.

Examples

Input

3 80
1 2 7

Output

2.000000000000

Explanation

Transfer 5 gallons from bucket 3 to bucket 1; 4 gallons are lost and 1 arrives. Each bucket now holds 2 gallons. A higher common amount requires more than 1 gallon for the first two buckets, but the last bucket has less than 5 gallons of surplus and can deliver less than 1 gallon.

Input

3 50
2 4 6

Output

3.500000000000

Explanation

Transfer 0.5 and 2.5 gallons from buckets 2 and 3 to bucket 1. It receives 0.25 and 1.25 gallons, reaching 3.5; the other two retain 3.5 each. A higher level leaves less than 3 gallons of surplus, delivering less than 1.5 gallons, insufficient for bucket 1.

Input

4 40
3 3 3 3

Output

3.000000000000

Explanation

All four buckets already contain 3 gallons, so no transfer is needed. The initial total is 12 gallons and transfers cannot increase it. Hence the common amount cannot exceed 12/4=312/4=3.