CF912C.Perun, Ult!
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A lot of students spend their winter holidays productively. Vlad has advanced very well in doing so! For three days already, fueled by salads and tangerines — the leftovers from New Year celebration — he has been calibrating his rating in his favorite MOBA game, playing as a hero named Perun.
Perun has an ultimate ability called "Thunderwrath". At the instant of its activation, each enemy on the map (n of them in total) loses
health points as a single-time effect. It also has a restriction: it can only activated when the moment of time is an integer. The initial bounty for killing an enemy is
. Additionally, it increases by
each second. Formally, if at some second t the ability is activated and the i-th enemy is killed as a result (i.e. his health drops to zero or lower), Vlad earns
units of gold.
Every enemy can receive damage, as well as be healed. There are multiple ways of doing so, but Vlad is not interested in details. For each of n enemies he knows:
— maximum number of health points for the i-th enemy;
— initial health of the enemy (on the 0-th second);
— the amount of health the i-th enemy can regenerate per second.
There also m health updates Vlad knows about:
— time when the health was updated;
— the enemy whose health was updated;
— updated health points for enemy__j.
Obviously, Vlad wants to maximize his profit. If it's necessary, he could even wait for years to activate his ability at the right second. Help him determine the exact second (note that it must be an integer) from 0 (inclusively) to + ∞ so that a single activation of the ability would yield Vlad the maximum possible amount of gold, and print this amount.
许多学生都以富有成效的方式度过寒假。弗拉德在这方面进步显著!在连续三天里,依靠新年庆祝活动剩下的沙拉和橘子作为能量补给,他一直在自己最喜爱的MOBA游戏中扮演英雄“佩伦”(Perun),校准自己的段位评分。
佩伦拥有一项终极技能,名为“雷霆之怒”(Thunderwrath)。该技能激活瞬间,地图上的每个敌人(共 n 个)都会受到一次性的 a 点伤害。该技能还有一项限制:仅能在整数时刻激活。击杀一名敌人的初始赏金为 b。此外,该赏金每秒增加 c。形式化地讲,若该技能于某秒 t 激活,并因此击杀了第 i 个敌人(即其生命值降至 0 或更低),则弗拉德将获得 b+c⋅t 单位金币。
每个敌人均可受到伤害,也可被治疗。实现方式多种多样,但弗拉德并不关心具体细节。对于这 n 个敌人中的每一个,他已知:
- hi —— 第 i 个敌人的最大生命值;
- xi —— 敌人初始生命值(即第 0 秒时的生命值);
- ri —— 第 i 个敌人每秒的生命恢复量。
此外,弗拉德还掌握了 m 次生命值更新信息:
- tj —— 生命值更新发生的时刻;
- ij —— 生命值被更新的敌人编号;
- xj′ —— 敌人 ij 更新后的新生命值。
显然,弗拉德希望最大化自己的收益。如有必要,他甚至可以等待数年,只为在最恰当的整数时刻激活该技能。请帮助他确定一个精确的激活时刻(注意:该时刻必须为整数),取值范围为从 0(含)到 +∞,使得单次技能激活能为弗拉德带来最大可能的金币收益,并输出该最大金币数额。
输入格式
In the first line, two integers are given (separated by spaces) — n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105).
In the second line, there are three integers:
,
and
(
,
).
Each of the following n lines has three integers —
,
,
(
,
).
The next m lines contain three integers each —
,
,
(
,
,
). It is guaranteed that there is no more than one hearth change per second for each enemy: more formally, for each a, b so that 1 ≤ a, b ≤ m, a ≠ b holds that if
, then
.
第一行给出两个整数(以空格分隔)——n 和 m(1 ≤ n ≤ 105,0 ≤ m ≤ 105)。
第二行给出三个整数:
、
和
(其中
,
)。
接下来的 n 行,每行包含三个整数 ——
、
、
(其中
,
)。
接下来的 m 行,每行包含三个整数 ——
、
、
(其中
,
,
)。保证每个敌人每秒至多发生一次炉心变化:更严格地说,对任意满足 1 ≤ a, b ≤ m 且 a = b 的 a, b,若
,则必有
。
输出格式
Output the single integer — the maximum amount of gold Vlad can obtain if he applies "Thunderwrath" exactly once, or -1 if this amount can be infinitely large.
输出一个整数——即弗拉德恰好施放一次“雷霆之怒”所能获得的最大金币数量;若该数量可以无限大,则输出 −1。
输入输出样例
输入#1
3 2 1000 10 50 70 5 5 90 70 1 110 20 2 20 2 10 30 3 10
输出#1
3000
输入#2
1 1 500 50 1000 750 750 20 10 1 300
输出#2
-1
说明/提示
On the pictures you can see health points of each enemy versus time in sample cases.
Periods when Vlad can kill one enemy are marked with yellow color.
Periods when Vlad can kill two enemies are marked with purple color.

In the first sample case, Vlad can activate the ability at the 50-th second: the enemies 2 and 3 will die since they would have 40 and 50 health points correspondingly. Vlad will earn 2·(1000 + 50·10) = 3000 gold.

In the second sample case, the maximum amount of health for the enemy 1 is less than the damage dealt by the ability. Hence, the enemy could be killed anytime. As the bounty increases by 50 over the time, the maximum possible amount of gold is infinite.
在图中,您可以观察到样例中每个敌人的生命值随时间的变化情况。
黄色标记的时段表示弗拉德可以击杀一名敌人的时段。
紫色标记的时段表示弗拉德可以同时击杀两名敌人的时段。

在第一个样例中,弗拉德可在第 50 秒激活技能:此时敌人 2 和敌人 3 的生命值分别为 40 和 50,均将被击杀。弗拉德将获得 2⋅(1000+50⋅10)=3000 金币。

在第二个样例中,敌人 1 的最大生命值小于技能所造成的伤害。因此,该敌人可在任意时刻被击杀。由于赏金随时间推移每单位时间增加 50,故所能获得的最大金币数量为无穷大。
输入解题思路,AI测评打分。不知道怎么写?