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 n different weapons and exactly one of m different armor sets. Weapon i has attack modifier ai and is worth cai coins, and armor set j has defense modifier bj and is worth cbj coins.
After choosing his equipment Roma can proceed to defeat some monsters. There are p monsters he can try to defeat. Monster k has defense xk , attack yk and possesses zk 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 k can be defeated with a weapon i and an armor set j if ai>xk and bj>yk . 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 n , m , and p ( 1≤n,m,p≤2⋅105 ) — the number of available weapons, armor sets and monsters respectively.
The following n lines describe available weapons. The i -th of these lines contains two integers ai and cai ( 1≤ai≤106 , 1≤cai≤109 ) — the attack modifier and the cost of the weapon i .
The following m lines describe available armor sets. The j -th of these lines contains two integers bj and cbj ( 1≤bj≤106 , 1≤cbj≤109 ) — the defense modifier and the cost of the armor set j .
The following p lines describe monsters. The k -th of these lines contains three integers xk,yk,zk ( 1≤xk,yk≤106 , 1≤zk≤103 ) — defense, attack and the number of coins of the monster k .
输出格式
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