QOJ.ac

QOJ

Time Limit: 12 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#887. 기말고사

Statistics

Rikka는 재능 있는 학생입니다. 그녀는 거의 매일 ICPC에 시간을 쏟지만, 기말고사가 다가오고 있습니다. Rikka는 시험 전 마지막 순간을 활용해 과목들을 복습할 계획입니다. 그녀에게는 복습을 위해 최대 $M$분의 시간이 주어지며, 이후 $n$개의 시험을 연속으로 치릅니다. Rikka가 $i$번째 시험을 위해 $x$분 동안 복습한다면, 시험별 매개변수 $a_i, b_i, c_i, d_i$에 따라 $f_i(x) = \max\{0, \min\{d_i, a_ix^2 + b_ix + c_i\}\}$ 점을 얻게 됩니다. Rikka는 $n$개 시험의 총점을 최대화하고 싶어 합니다. 특정 과목을 복습하는 데 사용하는 시간은 음수가 아닌 임의의 실수가 될 수 있습니다. 또한, 그녀는 ICPC에 더 많은 시간을 쓰기 위해 $M$분 전체를 복습에 다 사용할 필요는 없습니다.

입력

첫 번째 줄에는 정수 $n$과 실수 $M$이 주어집니다. 이어지는 $n$개의 줄에는 각 시험의 매개변수인 네 개의 실수 $a_i, b_i, c_i, d_i$가 주어집니다. $1 \le n \le 100\,000$, $0 < M \le 10^8$, $|a_i| \le 10$, $|b_i| \le 5000$, $0 \le c_i \le d_i \le 5000$임이 보장되며, 입력으로 주어지는 모든 실수는 소수점 셋째 자리까지 주어집니다. $a_i > 0$인 시험은 최대 18개임이 보장됩니다.

출력

Rikka가 얻을 수 있는 최대 총점 $d$를 출력하십시오. 정답을 $d^*$라고 할 때, $\frac{|d-d^*|}{\max\{d^*, 1\}} \le 10^{-6}$을 만족해야 합니다.

예제

입력 1

4 2.000
0.000 7.000 3.000 10.000
-1.000 10.000 3.000 10.000
-2.000 10.000 3.000 10.000
-3.000 10.000 3.000 10.000

출력 1

29.5734198185

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#487Editorial Open集训队作业 解题报告 by 何宇翔Qingyu2025-12-31 11:52:14 Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.