QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#14797. 昆虫

الإحصائيات

Sophie 在一家生产昆虫诱饵的公司工作。每种诱饵都包含三种成分:引诱剂(attractor)、饲料(feed)和毒药(poison)。此外,对于 $n$ 种昆虫中的每一种,都存在唯一的一个三元组成分可以消灭它。为了简化流程,引诱剂、饲料和毒药都进行了编号。

Sophie 正在设计一种全新的昆虫诱饵。它不需要杀死所有的昆虫,而是旨在最大化公司的利润。生产成本取决于诱饵中所含的不同引诱剂、饲料和毒药的数量。具体来说,它是所有这些成分单价的总和。方便的是,所有引诱剂的单价都是相同的,饲料和毒药也是如此。至于市场价格,公司的政策是根据诱饵能够杀死的昆虫种类数量来收费。具体来说,诱饵的价格是这个数量乘以 $p$(即所谓的“单虫收益系数”)。这种昆虫诱饵的单位利润是其价格与生产成本之间的差额。

帮助 Sophie 设计最赚钱的昆虫诱饵。编写一个程序,读取昆虫数量、单虫收益系数、引诱剂、饲料和毒药的成本,确定每单位诱饵可能获得的最大利润,并输出该结果。

输入格式

输入的第一行给出整数 $n, p, c_a, c_k, c_t$($1 \le n, p, c_a, c_k, c_t \le 1000$),由单个空格分隔。它们依次为:昆虫种类数量、单虫收益系数,以及引诱剂、饲料和毒药的单位成本。

接下来的 $n$ 行描述了昆虫种类,每行一个。每个描述由三个整数 $a_i, k_i, t_i$($0 \le a_i, k_i, t_i < 256$)组成,由单个空格分隔;这表示第 $i$ 种昆虫可以通过组合引诱剂 $a_i$、饲料 $k_i$ 和毒药 $t_i$ 来消灭。

保证输入中给出的三元组 $(a_i, k_i, t_i)$ 两两不同。

输出格式

你的程序应该输出一个整数:每单位昆虫诱饵可能获得的最大利润。

样例

输入样例 1

5 10 3 10 1
127 127 127
0 0 127
255 127 0
127 127 0
64 64 64

输出样例 1

12

说明

该诱饵应由引诱剂 $127$ 和 $255$(成本为 $2 \cdot 3 = 6$)、饲料 $127$(成本为 $1 \cdot 10 = 10$)以及毒药 $0$ 和 $127$(成本为 $2 \cdot 1 = 2$)组成,总生产成本为 $18$。这种诱饵可以杀死第 1、3 和 4 种昆虫,因此其价格为 $30$。因此,该诱饵的单位利润为 $12$。

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.