CF1320C.World of Darkraft: Battle for Azathoth

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Roma is playing a new expansion for his favorite game World of Darkraft. He made a new character and is going for his first grind.

Roma has a choice to buy exactly one of nn different weapons and exactly one of mm different armor sets. Weapon ii has attack modifier aia_i and is worth caica_i coins, and armor set jj has defense modifier bjb_j and is worth cbjcb_j coins.

After choosing his equipment Roma can proceed to defeat some monsters. There are pp monsters he can try to defeat. Monster kk has defense xkx_k, attack yky_k and possesses zkz_k coins. Roma can defeat a monster if his weapon's attack modifier is larger than the monster's defense, and his armor set's defense modifier is larger than the monster's attack. That is, a monster kk can be defeated with a weapon ii and an armor set jj if ai>xka_i \gt x_k and bj>ykb_j \gt y_k. After defeating the monster, Roma takes all the coins from them. During the grind, Roma can defeat as many monsters as he likes. Monsters do not respawn, thus each monster can be defeated at most one.

Thanks to Roma's excessive donations, we can assume that he has an infinite amount of in-game currency and can afford any of the weapons and armor sets. Still, he wants to maximize the profit of the grind. The profit is defined as the total coins obtained from all defeated monsters minus the cost of his equipment. Note that Roma must purchase a weapon and an armor set even if he can not cover their cost with obtained coins.

Help Roma find the maximum profit of the grind.

罗玛正在玩他最喜爱的游戏《暗黑纪元》(World of Darkraft)的新资料片。他创建了一个新角色,准备开始首次刷怪。

罗玛必须恰好从 nn 种不同的武器中选择一种,且恰好从 mm 种不同的护甲套装中选择一套。武器 ii 的攻击力加成为 aia_i,售价为 caica_i 金币;护甲套装 jj 的防御力加成为 bjb_j,售价为 cbjcb_j 金币。

选定装备后,罗玛即可挑战若干怪物。共有 pp 只怪物可供挑战。怪物 kk 的防御力为 xkx_k、攻击力为 yky_k,击败后可获得 zkz_k 金币。罗玛能够击败怪物 kk,当且仅当他所选武器的攻击力加成严格大于该怪物的防御力,且所选护甲套装的防御力加成严格大于该怪物的攻击力。即:使用武器 ii 和护甲套装 jj 能击败怪物 kk 的充要条件是 ai>xka_i \gt x_k 且 bj>ykb_j \gt y_k。击败怪物后,罗玛将获得其全部金币。在整个刷怪过程中,罗玛可以击败任意数量的怪物(只要满足条件),但怪物不会刷新,因此每只怪物最多只能被击败一次。

得益于罗玛巨额的充值,我们可以假定他拥有无限的游戏内货币,能够负担得起任意武器和护甲套装。然而,他仍希望最大化本次刷怪的收益。收益定义为:所有被击败怪物所获金币总和减去所购装备的总花费。注意:即使罗玛无法通过击败怪物获得足够金币来覆盖装备开销,他也必须购买一件武器和一套护甲。

请帮助罗玛计算本次刷怪所能获得的最大收益。

输入格式

The first line contains three integers nn, mm, and pp (1≤n,m,p≤2⋅1051 \leq n, m, p \leq 2 \cdot 10^5) — the number of available weapons, armor sets and monsters respectively.

The following nn lines describe available weapons. The ii-th of these lines contains two integers aia_i and caica_i (1≤ai≤1061 \leq a_i \leq 10^6, 1≤cai≤1091 \leq ca_i \leq 10^9) — the attack modifier and the cost of the weapon ii.

The following mm lines describe available armor sets. The jj-th of these lines contains two integers bjb_j and cbjcb_j (1≤bj≤1061 \leq b_j \leq 10^6, 1≤cbj≤1091 \leq cb_j \leq 10^9) — the defense modifier and the cost of the armor set jj.

The following pp lines describe monsters. The kk-th of these lines contains three integers xk,yk,zkx_k, y_k, z_k (1≤xk,yk≤1061 \leq x_k, y_k \leq 10^6, 1≤zk≤1031 \leq z_k \leq 10^3) — defense, attack and the number of coins of the monster kk.

第一行包含三个整数 nn、mm 和 pp(1≤n,m,p≤2⋅1051 \leq n, m, p \leq 2 \cdot 10^5),分别表示可用武器数量、可用护甲套装数量以及怪物数量。

接下来的 nn 行描述可用武器。其中第 ii 行包含两个整数 aia_i 和 caica_i(1≤ai≤1061 \leq a_i \leq 10^6,1≤cai≤1091 \leq ca_i \leq 10^9),分别表示第 ii 件武器的攻击力加成和价格。

接下来的 mm 行描述可用护甲套装。其中第 jj 行包含两个整数 bjb_j 和 cbjcb_j(1≤bj≤1061 \leq b_j \leq 10^6,1≤cbj≤1091 \leq cb_j \leq 10^9),分别表示第 jj 套护甲的防御力加成和价格。

接下来的 pp 行描述怪物。其中第 kk 行包含三个整数 xkx_k、yky_k、zkz_k(1≤xk,yk≤1061 \leq x_k, y_k \leq 10^6,1≤zk≤1031 \leq z_k \leq 10^3),分别表示第 kk 个怪物的防御力、攻击力以及金币数量。

输出格式

Print a single integer — the maximum profit of the grind.

输出一个整数——该研磨操作所能获得的最大利润。

输入输出样例

  • 输入#1

    2 3 3
    2 3
    4 7
    2 4
    3 2
    5 11
    1 2 4
    2 1 6
    3 4 6

    输出#1

    1

输入解题思路,AI测评打分。不知道怎么写?

首页