CF1651F.Tower Defense
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Monocarp is playing a tower defense game. A level in the game can be represented as an OX axis, where each lattice point from 1 to n contains a tower in it.
The tower in the i-th point has ci mana capacity and ri mana regeneration rate. In the beginning, before the 0-th second, each tower has full mana. If, at the end of some second, the i-th tower has x mana, then it becomes min(x+ri,ci) mana for the next second.
There are q monsters spawning on a level. The j-th monster spawns at point 1 at the beginning of tj-th second, and it has hj health. Every monster is moving 1 point per second in the direction of increasing coordinate.
When a monster passes the tower, the tower deals min(H,M) damage to it, where H is the current health of the monster and M is the current mana amount of the tower. This amount gets subtracted from both monster's health and tower's mana.
Unfortunately, sometimes some monsters can pass all n towers and remain alive. Monocarp wants to know what will be the total health of the monsters after they pass all towers.
Monocarp 正在玩一款塔防游戏。游戏中的一关可以表示为一条 OX 轴,其中从 1 到 n 的每个整数坐标点上都有一座塔。
第 i 座塔的法力容量为 ci,法力恢复速率为 ri。初始时(即第 0 秒之前),每座塔均拥有满法力。若某座塔在某一秒结束时拥有 x 点法力,则它在下一秒开始时的法力值为 min(x+ri,ci)。
本关中共有 q 只怪物生成。第 j 只怪物于第 tj 秒初在坐标点 1 处生成,其生命值为 hj。每只怪物每秒沿坐标增大的方向移动 1 个单位距离。
当一只怪物经过某座塔时,该塔对其造成 min(H,M) 点伤害,其中 H 是怪物当前的生命值,M 是该塔当前的法力值。该伤害值将同时从怪物的生命值和塔的法力值中扣除。
不幸的是,有时部分怪物可能成功穿过全部 n 座塔并依然存活。Monocarp 想知道:所有怪物穿过全部塔之后,它们剩余生命值的总和是多少?
输入格式
The first line contains a single integer n (1≤n≤2⋅105) — the number of towers.
The i-th of the next n lines contains two integers ci and ri (1≤ri≤ci≤109) — the mana capacity and the mana regeneration rate of the i-th tower.
The next line contains a single integer q (1≤q≤2⋅105) — the number of monsters.
The j-th of the next q lines contains two integers tj and hj (0≤tj≤2⋅105; 1≤hj≤1012) — the time the j-th monster spawns and its health.
The monsters are listed in the increasing order of their spawn time, so tj<tj+1 for all 1≤j≤q−1.
第一行包含一个整数 n(1≤n≤2⋅105)—— 塔的数量。
接下来的 n 行中,第 i 行包含两个整数 ci 和 ri(1≤ri≤ci≤109)—— 第 i 座塔的法力容量与法力恢复速率。
接下来一行包含一个整数 q(1≤q≤2⋅105)—— 怪物的数量。
接下来的 q 行中,第 j 行包含两个整数 tj 和 hj(0≤tj≤2⋅105;1≤hj≤1012)—— 第 j 只怪物的生成时间及其生命值。
怪物按生成时间升序列出,即对所有 1≤j≤q−1,均有 tj<tj+1。
输出格式
Print a single integer — the total health of all monsters after they pass all towers.
输出一个整数——所有怪物经过所有塔后的总生命值。
输入输出样例
输入#1
3 5 1 7 4 4 2 4 0 14 1 10 3 16 10 16
输出#1
4
输入#2
5 2 1 4 1 5 4 7 5 8 3 9 1 21 2 18 3 14 4 24 5 8 6 25 7 19 8 24 9 24
输出#2
40
输入解题思路,AI测评打分。不知道怎么写?