CF1320C.World of Darkraft: Battle for Azathoth

普及/提高-

通过率:0%

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 > x_k and bj>ykb_j > 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.

输入格式

The first line contains three integers nn , mm , and pp ( 1n,m,p21051 \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 ( 1ai1061 \leq a_i \leq 10^6 , 1cai1091 \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 ( 1bj1061 \leq b_j \leq 10^6 , 1cbj1091 \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 ( 1xk,yk1061 \leq x_k, y_k \leq 10^6 , 1zk1031 \leq z_k \leq 10^3 ) — defense, attack and the number of coins of the monster 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
首页