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

建议使用的浏览器:

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

3989:Harry Potter and the Polyjuice Potion

题目描述
Polyjuice potion is one of the most famous magic medicines in Harry Porter which had been made by our talented witch Hermione Jean Granger when she was a little girl. But at the very beginning, she didn't know the prescription, so she had to try several materials to make it up. After that, she found there were only twenty materials which could possibly make the polyjuice potion. And she also noticed that some combination of the materials of the twenty materials will get an effect Ei(-1000 < Ei < 1000).If she choose a subset S of the materials, the final effect will be the sum of effect values of all combinations appeared in S. Because Hermione is very clever, she calculated all the effect value of the combinations. So what's the maximum effect value the polyjuice potion will get?

输入解释
Input contains multiple test cases(at most 10).
For each test case, the first line contains a positive integer N(N <= 100000) indicate the number of the combinations.
Then N lines follow, each line contains two number c (0 <= c < 2^20), v(-1000 < v < 1000),indicate the effect value of the combination c (binary representation).
Input ends with a negtive number.

输出解释
For each test case output a number indicates the maximum value of the polyjuice potion.
输入样例
3
1 9
2 -10
3 300
-1
输出样例
299
来自杭电HDUOJ的附加信息
Author fatboy_cw@WHU
Recommend lcy

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

源链接: HDU-3989

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

共提交 0

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