QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 128 MB 總分: 100

#8499. 反物质

统计

一家公司正在测试一种制取反物质的技术,反物质将用作行星际飞船的燃料。反物质通过在反应堆中进行特殊实验制得。

已知有 $n$ 种能够制取反物质的实验。进行第 $i$ 种实验后,反应堆的输出容器中会增加 $l_i$ 到 $r_i$ 克反物质。出于安全考虑,容器中积存的反物质不得超过 $a$ 克。

进行第 $i$ 种实验的成本为 $c_i$,而制得的每克反物质的价值为 $10^9$。

如果实验结束后容器中有 $t$ 克反物质,在反应堆中进行实验的总成本为 $s$,则利润为 $t\cdot10^9-s$。公司需要制定一种实验策略,使能够保证获得的利润最大化。

策略根据先前实验的结果决定接下来进行哪一种实验,或者决定停止继续实验。如果对于实验的任何可能结果,首先反应堆容器中的反物质不超过 $a$ 克,其次利润不少于 $x$,则称该策略能够保证获得利润 $x$。

例如,假设只有一种实验,每次产生 $4$ 到 $6$ 克反物质,成本为 $10$,容器的容量为 $17$ 克。那么进行两次实验后,容器中可能有 $8$ 到 $12$ 克反物质。如果产生了 $12$ 克,就不能再进行实验,因为如果再产生 $6$ 克反物质,容器就可能超出容量。在其他情况下,可以进行第三次实验,得到 $12$ 到 $17$ 克反物质。最坏情况下需要进行三次实验,总成本为 $30$,利润为 $(12\cdot10^9-30)=11\,999\,999\,970$。

请编写一个程序,确定能够保证获得的最大利润 $x$。

输入格式

第一行包含两个整数:$n$ 表示实验种类数,$a$ 表示容器中允许存放的反物质的最大数量($1\le n\le100$,$1\le a\le2\,000\,000$)。

接下来 $n$ 行,每行包含三个整数 $l_i$、$r_i$ 和 $c_i$,分别表示第 $i$ 种实验所能产生的反物质的最小数量、最大数量以及该种实验的成本($1\le l_i\le r_i\le a$,$1\le c_i\le100$)。

输出格式

输出一个整数,表示能够保证获得的最大利润 $x$。

样例

输入格式 1

1 17
4 6 10

输出格式 1

11999999970

输入格式 2

2 11
2 2 100
3 5 5

输出格式 2

9999999890

子任务

子任务 分值 限制:$n$ 限制:$a$ 额外限制 所需子任务 比赛期间的结果
$1$ $10$ $n=1$ $1\le a\le1\,000$ 逐测试点
$2$ $10$ $1\le n\le10$ $1\le a\le1\,000$ $l_i=r_i$ 逐测试点
$3$ $20$ $1\le n\le10$ $1\le a\le1\,000$ $1,2$ 逐测试点
$4$ $20$ $1\le n\le100$ $1\le a\le50\,000$ $1\text{–}3$ 逐测试点
$5$ $4$ $1\le n\le100$ $1\le a\le100\,000$ $1\text{–}4$ 分数
$6$ $4$ $1\le n\le100$ $1\le a\le200\,000$ $1\text{–}5$ 分数
$7$ $4$ $1\le n\le100$ $1\le a\le300\,000$ $1\text{–}6$ 分数
$8$ $4$ $1\le n\le100$ $1\le a\le400\,000$ $1\text{–}7$ 分数
$9$ $4$ $1\le n\le100$ $1\le a\le500\,000$ $1\text{–}8$ 分数
$10$ $4$ $1\le n\le100$ $1\le a\le800\,000$ $1\text{–}9$ 分数
$11$ $4$ $1\le n\le100$ $1\le a\le1\,100\,000$ $1\text{–}10$ 分数
$12$ $4$ $1\le n\le100$ $1\le a\le1\,400\,000$ $1\text{–}11$ 分数
$13$ $4$ $1\le n\le100$ $1\le a\le1\,700\,000$ $1\text{–}12$ 分数
$14$ $4$ $1\le n\le100$ $1\le a\le2\,000\,000$ $1\text{–}13$ 分数

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.