CF865B.Ordering Pizza
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It's another Start[c]up finals, and that means there is pizza to order for the onsite contestants. There are only 2 types of pizza (obviously not, but let's just pretend for the sake of the problem), and all pizzas contain exactly S slices.
It is known that the i-th contestant will eat s__i slices of pizza, and gain a__i happiness for each slice of type 1 pizza they eat, and b__i happiness for each slice of type 2 pizza they eat. We can order any number of type 1 and type 2 pizzas, but we want to buy the minimum possible number of pizzas for all of the contestants to be able to eat their required number of slices. Given that restriction, what is the maximum possible total happiness that can be achieved?
又到了 Start[c]up 总决赛,这意味着需要为现场参赛者订购披萨。披萨仅有 2 种类型(显然现实中不止两种,但本题中我们仅作此假设),且每种披萨均恰好包含 S 片。
已知第 i 位参赛者将吃掉 s__i 片披萨,且每吃一片类型 1 的披萨可获得 a__i 点快乐值,每吃一片类型 2 的披萨可获得 b__i 点快乐值。我们可以任意订购类型 1 和类型 2 的披萨数量,但目标是购买最少可能的披萨总数,使得所有参赛者都能吃到各自所需的片数。在满足该约束的前提下,所能达到的最大总快乐值是多少?
输入格式
The first line of input will contain integers N and S (1 ≤ N ≤ 105, 1 ≤ S ≤ 105), the number of contestants and the number of slices per pizza, respectively. N lines follow.
The i-th such line contains integers s__i, a__i, and b__i (1 ≤ s__i ≤ 105, 1 ≤ a__i ≤ 105, 1 ≤ b__i ≤ 105), the number of slices the i-th contestant will eat, the happiness they will gain from each type 1 slice they eat, and the happiness they will gain from each type 2 slice they eat, respectively.
输入的第一行包含两个整数 N 和 S(1 ≤ N ≤ 105,1 ≤ S ≤ 105),分别表示参赛者人数和每张披萨的片数。随后是 N 行。
第 i 行包含三个整数 si、ai 和 bi(1 ≤ si ≤ 105,1 ≤ ai ≤ 105,1 ≤ bi ≤ 105),分别表示第 i 位参赛者将吃的披萨片数、每吃一片类型 1 披萨所获得的快乐值,以及每吃一片类型 2 披萨所获得的快乐值。
输出格式
Print the maximum total happiness that can be achieved.
输出所能达到的最大总幸福感。
输入输出样例
输入#1
3 12 3 5 7 4 6 7 5 9 5
输出#1
84
输入#2
6 10 7 4 7 5 8 8 12 5 8 6 11 6 3 3 7 5 9 6
输出#2
314
说明/提示
In the first example, you only need to buy one pizza. If you buy a type 1 pizza, the total happiness will be 3·5 + 4·6 + 5·9 = 84, and if you buy a type 2 pizza, the total happiness will be 3·7 + 4·7 + 5·5 = 74.
在第一个例子中,你只需购买一个披萨。如果你购买一个类型 1 的披萨,总幸福感为 3⋅5+4⋅6+5⋅9=84;而如果你购买一个类型 2 的披萨,总幸福感为 3⋅7+4⋅7+5⋅5=74。
输入解题思路,AI测评打分。不知道怎么写?