当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6532:Chessboard

题目描述
There are $N$ chess pieces on a huge chessboard of $10^9\times10^9$ ( the rows are numbered from $1$ to $10^9$ from top to bottom and the columns are numbered from $1$ to $10^9$ from left to right ) . All pieces are located in different grids , and the $i$-th piece is in the $y_i$-th column of the $x_i$-th row . All pieces have their own values , and the value of the $i$-th piece is exactly $i$ .

Your task is to take the chess pieces and maximize the sum of values of the pieces you take . But there are $M$ conditions of the following two types that should be met :

- " R $i$ $k$ " — there is a dividing line between the ($i-1$)-th row and the $i$-th row , and you can take up to $k$ from the pieces under the line ;
- " C $i$ $k$ " — there is a dividing line between the ($i-1$)-th column and the $i$-th column , and you can take up to $k$ from the pieces on the right of the line .
输入解释
The first line contains integer $N$ ( $1\leq N\leq500$ ) , denotes the number of chess pieces .

For the next $N$ lines , the $i$-th line contains two integers $x_i$ and $y_i$ , denotes the position of the $i$-th piece whose value is also $i$ .

The ($N+2$)-th line contains integer $M$ ( $1\leq M\leq10^5$ ) , denotes the number of conditions .

Then $M$ lines follow , describing conditions in the format given in the statement .

All input integers are between $1$ and $10^9$ .
输出解释
Print the maximal sum of values of the chess pieces you take .
输入样例
4
1 2
2 2
3 1
3 2
4
R 2 3
C 1 4
R 3 1
C 2 2
输出样例
6

提示
You can take the first three pieces ( or take the second piece and the fourth piece ) .
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6532

最后修改于 2020-10-25T23:32:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)