5527: Did I miss the lethal?

内存限制:256 MB 时间限制:20.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

输入

输出

样例输入 复制

2
3
3 1
4 2
5 2
6
10 1
10 1
15 2
20 3
20 3
25 4

样例输出 复制

7
40

提示

For the first test case of the sample, the optimal strategy for -skyline- is to play the first card, then play the only remaining card that is not discarded. In this case, -skyline- can deal a total of 3+4=7 damage to the enemy hero in the worst case.