A11209 | Ordering Pizza
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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?
输入格式
The first line of input will contain integers $N$ and $S$ $(1<=N<=10^{5},1<=S<=10^{5})$ , 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}<=10^{5},1<=a_{i}<=10^{5},1<=b_{i}<=10^{5})$ , 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.
The $i$ -th such line contains integers $s_{i}$ , $a_{i}$ , and $b_{i}$ $(1<=s_{i}<=10^{5},1<=a_{i}<=10^{5},1<=b_{i}<=10^{5})$ , 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.
输出格式
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted