루미 알고리즘

#1507골드Drone Flying

PO 2021 결선코딩출제 Ivar Källström영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

You have just gotten a new battery-powered drone, but you lack batteries. In the store, there are N batteries available for the drone, each with an energy e_i, weight w_i, and cost c_i. The store has only one of each battery.

To have as much fun as possible with the drone, you obviously want it to fly as long as possible on a full charge. The time the drone can stay in the air is given by the expression t = (E_tot)/(W_tot) where E_tot is the total energy content of all the drone's batteries, and W_tot is the combined weight of the drone and the batteries.

Given a budget B and the weight of the drone itself W, determine the maximum time the drone can fly.

Input

The first line contains three integers N, B, and W (1 ≤ N × B ≤ 200,000 and 1 ≤ W ≤ 1000), the number of available batteries, your budget, and the weight of the drone.

The following N lines each contain three integers. Line number i contains e_i, w_i, and c_i (0 ≤ e_i ≤ 1000, 0 ≤ w_i ≤ 1000, 0 ≤ c_i ≤ B), the energy, weight, and cost of battery i.

Output

Print a decimal number: The longest time you can fly your drone if you choose the batteries optimally. The answer will be accepted if it has a relative or absolute error of at most 10^-5. That is, if your answer is a and the correct answer is b, your answer will be accepted if either |a-b| ≤ 10^-5 or (|a-b|)/(|b|) ≤ 10^-5.

Points

Your solution will be tested on several test case groups. To get the points for a group, it must pass all the test cases in the group.

GroupPoint valueConstraints
110N ≤ 20
220w_i = 0
320c_1 = c_2 = … = c_N
450No additional constraints.

예제

예제 1

입력
10 1000 20
40 40 40
1 1 1
70 30 60
100 20 700
80 50 200
30 1 200
100 100 1
20 1 500
30 20 100
70 50 100
출력
3.17073170731707

출처 표기

출처: Programmeringsolympiaden 2021년 결선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.