QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 256 MB 总分: 100

#6091. 墨西哥卷饼之王

统计

两位朋友 Albert 和 Barney 来到了新开张的“Burrito King”餐厅。这家餐厅昨天才开业,Albert 拿到了一张特别礼品卡,可以让朋友们免费享用一份墨西哥卷饼。然而,配料的用量有限制——对于所有 $1$ 到 $n$ 之间的 $i$,卷饼中第 $i$ 种配料的含量最多为 $g_i$ 克。

每种配料都有两个满意度参数 $a_i$ 和 $b_i$——分别代表每克该配料带给 Albert 的快乐值,以及每克该配料带给 Barney 的不悦值。

因此,Albert 从卷饼中获得的总快乐值为: $$\sum_{i=1}^{n} s_i \cdot a_i$$

Barney 从卷饼中获得的总不悦值为: $$\sum_{i=1}^{n} s_i \cdot b_i$$

其中 $s_i$ 是卷饼中第 $i$ 种配料的克数。注意,$s_i$ 不一定是整数,且 $0 \le s_i \le g_i$。

Albert 希望他从卷饼中获得的总快乐值至少为 $A$。由于 Barney 是他最好的朋友,Albert 希望 Barney 的总不悦值不超过 $B$。在所有满足上述约束的卷饼配方中,Albert 希望选择一种能使他的总快乐值最大化的方案。

你的任务是帮助 Albert 选择 $s_i$ 以满足这些条件,或者判断是否存在可行解。

输入格式

第一行包含三个整数 $n$、$A$ 和 $B$ ($1 \le n \le 100\,000$,$0 \le A, B \le 10^9$),分别表示配料种类数、Albert 所需的最小快乐值以及 Barney 所能承受的最大不悦值。接下来的 $n$ 行,每行包含三个整数 $g_i, a_i, b_i$ ($0 \le g_i, a_i, b_i \le 100$),分别表示第 $i$ 种配料允许的最大克数、每克带给 Albert 的快乐值以及每克带给 Barney 的不悦值。

输出格式

输出的第一行必须包含两个实数——在满足题目条件的前提下,Albert 能获得的最大快乐值以及对应的 Barney 的总不悦值;如果 Albert 无法满足条件,则输出 “-1 -1”。

如果条件满足,第二行必须包含 $n$ 个实数——每种配料的克数。

你的输出必须保证绝对误差或相对误差不超过 $10^{-8}$。

任何能达到最大快乐值且满足给定条件的方案均可。

样例

样例输入 1

2 5 5
2 2 1
2 2 4

样例输出 1

5.5 5
2 0.75

样例输入 2

2 5 5
2 2 2
2 2 4

样例输出 2

-1 -1

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.