CF453E.Little Pony and Lord Tirek
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Lord Tirek is a centaur and the main antagonist in the season four finale episodes in the series "My Little Pony: Friendship Is Magic". In "Twilight's Kingdom" (Part 1), Tirek escapes from Tartarus and drains magic from ponies to grow stronger.

The core skill of Tirek is called Absorb Mana. It takes all mana from a magic creature and gives them to the caster.
Now to simplify the problem, assume you have n ponies (numbered from 1 to n). Each pony has three attributes:
- s__i : amount of mana that the pony has at time 0;
- m__i : maximum mana that the pony can have;
- r__i : mana regeneration per unit time.
Lord Tirek will do m instructions, each of them can be described with three integers: t__i, l__i, r__i. The instruction means that at time t__i, Tirek will use Absorb Mana on ponies with numbers from l__i to r__i (both borders inclusive). We'll give you all the m instructions in order, count how much mana Tirek absorbs for each instruction.
提雷克勋爵是一只半人马,也是动画系列《小马宝莉:友谊就是魔法》第四季 finale 集的主要反派角色。在《暮光之城》(第一部分)中,提雷克从塔尔塔罗斯逃脱,并吸取小马们的魔法以增强自身力量。

提雷克的核心技能名为“吸收法力”(Absorb Mana),该技能会将目标魔法生物的全部法力瞬间抽取,并转移给施法者。
现为简化问题,假设你有 n 匹小马(编号从 1 到 n)。每匹小马具有以下三个属性:
- si:时刻 0 时该小马所拥有的法力值;
- mi:该小马所能拥有的最大法力值;
- ri:单位时间内该小马的法力恢复速率。
提雷克勋爵将执行 m 条指令,每条指令由三个整数 ti,li,ri 描述。该指令表示:在时刻 ti,提雷克将对编号在区间 [li,ri](含端点)内的所有小马施放“吸收法力”。我们将按顺序给出全部 m 条指令,请依次计算并输出每条指令中提雷克所吸收的总法力值。
输入格式
The first line contains an integer n (1 ≤ n ≤ 105) — the number of ponies. Each of the next n lines contains three integers s__i, m__i, r__i (0 ≤ s__i ≤ m__i ≤ 105; 0 ≤ r__i ≤ 105), describing a pony.
The next line contains an integer m (1 ≤ m ≤ 105) — the number of instructions. Each of the next m lines contains three integers t__i, l__i, r__i (0 ≤ t__i ≤ 109; 1 ≤ l__i ≤ r__i ≤ n), describing an instruction of Lord Tirek. The instructions are given in strictly increasing order of t__i (all t__i are distinct).
第一行包含一个整数 n(1≤n≤105)——小马的数量。接下来的 n 行每行包含三个整数 si,mi,ri(0≤si≤mi≤105;0≤ri≤105),描述一匹小马。
接下来一行包含一个整数 m(1≤m≤105)——指令的数量。接下来的 m 行每行包含三个整数 ti,li,ri(0≤ti≤109;1≤li≤ri≤n),描述提雷克领主的一条指令。这些指令按 ti 严格递增顺序给出(所有 ti 均互不相同)。
输出格式
For each instruction, output a single line which contains a single integer, the total mana absorbed in this instruction.
对于每条指令,输出一行,包含一个整数,表示该指令中吸收的总法力值。
输入输出样例
输入#1
5 0 10 1 0 12 1 0 20 1 0 12 1 0 10 1 2 5 1 5 19 1 5
输出#1
25 58
说明/提示
Every pony starts with zero mana. For the first instruction, each pony has 5 mana, so you get 25 mana in total and each pony has 0 mana after the first instruction.
For the second instruction, pony 3 has 14 mana and other ponies have mana equal to their m__i.
每只小马初始拥有 0 点法力值。对于第一条指令,每只小马获得 5 点法力值,因此你总共获得 25 点法力值,且在执行完第一条指令后,每只小马的法力值均为 0。
对于第二条指令,小马 3 拥有 14 点法力值,其余小马的法力值等于其对应的 mi 值。
输入解题思路,AI测评打分。不知道怎么写?