PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000054. Bơm bóng bay (Inflation)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bơm bóng bay (Inflation)
Inflation
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are balloons of capacities and gas canisters containing units. Pair each canister with one balloon and empty it entirely without overfilling any balloon. Maximize the minimum filling fraction.
Input
Line 1: . Line 2: gas quantities .
Output
Print impossible if no matching is feasible; otherwise print the optimal fraction with absolute or relative error at most .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
1 2 2
Output
0.666666666667
Explanation
Match 1 to balloon size 1 and the two 2-unit canisters to sizes 2 and 3. The fractions are , so the optimal minimum is .