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

#BS0000402. Chọn cặp số (Pair Selection)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Chọn cặp số (Pair Selection)

Pair Selection

Version: Phuoc Hung OJ Extended

PHOJ practice edition. Its constraints, input/output format, examples and judging rules are specified below.

Statement

Given nn pairs of positive integers (ai,bi)(a_i,b_i), choose exactly kk distinct indices forming a set SS to maximize $$\frac{\sum_{i\in S}a_i}{\sum_{i\in S}b_i}.$$ Print the maximum ratio.

Input

The first line contains integers n,kn,k. Each of the next nn lines contains integers ai,bia_i,b_i.

Output

Print the maximum ratio. Absolute error must not exceed 10−610^{-6}. The output token may contain at most 128 characters; in scientific notation, the explicit exponent must be from -1000 to 1000.

Subtasks

  • Subtask 1 (20 points): 1≤n≤161\le n\le 16; 1≤k≤n1\le k\le n; 1≤ai,bi≤1041\le a_i,b_i\le10^4.
  • Subtask 2 (30 points): 1≤n≤5001\le n\le 500; 1≤k≤n1\le k\le n; 1≤ai,bi≤1041\le a_i,b_i\le10^4.
  • Subtask 3 (50 points): 1≤n≤100001\le n\le 10000; 1≤k≤n1\le k\le n; 1≤ai,bi≤1041\le a_i,b_i\le10^4.

New examples

Input

3 2
10 2
6 1
8 4

Output

5.333333333333333

Explanation

There are three ways to choose two pairs. Pairs 1 and 2 yield (10+6)/(2+1)=16/3(10+6)/(2+1)=16/3. Pairs 1 and 3 yield 18/6=318/6=3, while pairs 2 and 3 yield 14/5=2.814/5=2.8. The maximum is 16/316/3, approximately 5.3333333333333335.333333333333333.

Input

3 1
2 5
9 2
4 1

Output

4.5

Explanation

Only one pair is selected, so the possible ratios are 2/5=0.42/5=0.4, 9/2=4.59/2=4.5, and 4/1=44/1=4. The maximum is 4.5, attained by the second pair.

Input

2 2
1 3
5 2

Output

1.2

Explanation

Since n=k=2n=k=2, both pairs must be selected. The numerator is 1+5=61+5=6 and the denominator is 3+2=53+2=5, yielding 6/5=1.26/5=1.2.