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

建议使用的浏览器:

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

6557:Justice

Special Judge 特殊评判
题目描述
Put simply, the Justice card represents justice, fairness, truth and the law. You are being called to account for your actions and will be judged accordingly. If you have acted in a way that is in alignment with your Higher Self and for the greater good of others, you have nothing to worry about. However, if you have
acted in a way that is out of alignment, you will be called out and required to own up to your actions. If this has you shaking in your boots, know that the Justice card isn’t as black and white as you may think.


On the table there are n weights. On the body of the i-th weight carved a positive integer $k_i$ , indicating that its weight is $\frac{1}{2^{k_i}}$ gram. Is it possible to divide the n weights into two groups and make sure that the sum of the weights in each group is greater or equal to $\frac{1}{2}$ gram? That’s on your call. And please tell us how if possible.
输入解释
In the first line of the input there is a positive integer $T$ (1 ≤ $T$ ≤ 2000), indicating there are $T$ testcases.
In the first line of each of the $T$ testcases, there is a positive integer $n$ (1 ≤ $n$ ≤ $10^5$, ∑n ≤ 7 × $10^5$), indicating there are $n$ weights on the table.
In the next line, there are $n$ integers $k_i$ (1 ≤ ki ≤ $10^9$), indicating the number carved on each weight.
输出解释
For each testcase, first print Case $i$: ANSWER in one line, $i$ indicating the case number starting from $1$ and ANSWER should be either YES or NO, indicating whether or not it is possible to divide the weights. Pay attention to the space between : and ANSWER.
If it’s possible, you should continue to output the dividing solution by print a 0/1 string of length $n$ in the next line. The $i$-th character in the string indicating whether you choose to put the i-th weight in group 0 or group 1.
输入样例
3
3
2 2 2
3
2 2 1
2
1 1
输出样例
Case 1: NO
Case 2: YES
001
Case 3: YES
10
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6557

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

共提交 0

通过率 --%
时间上限 内存上限
7000/4000MS(Java/Others) 262144/262144K(Java/Others)