五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF:Fair Division

2023-04-22 15:40 作者:您是打尖兒還是住店呢  | 我要投稿

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Alice and Bob received?n??candies from their parents.?Each candy weighs either 1 gram or 2 grams. Now they want to divide all candies among themselves fairly so that the total weight of Alice's candies is equal to the total weight of Bob's candies.

Check if they can do that.

Note that candies?are not allowed to be cut in half.

Input

The first line contains one integer?t(1t104)?— the number of test cases. Then?t?test cases follow.

The first line of each test case contains an integer?n?(1n100)?— the number of candies that Alice and Bob received.

The next line contains?nintegers?a1,a2,,an?— the weights of the candies. The weight of each candy is either?1or?2.

It is guaranteed that the sum of?n?over all test cases does not exceed?105.

Output

For each test case, output on a separate line:

  • "YES", if all candies can be divided into two sets with the same weight;

  • "NO" otherwise.

You can output "YES" and "NO" in any case (for example, the strings?yEs,?yes,?Yes?and?YES?will be recognized as positive).

Example

input

5?

2

1 1?

2

1 2

4

1 2 1 2

3

2 2 2

3

2 1 2

output

YES?

NO?

YES?

NO?

NO

Note

In the first test case, Alice and Bob can each take one candy, then both will have a total weight of?1.

In the second test case, any division will be unfair.

In the third test case, both Alice and Bob can take two candies, one of weight?11?and one of weight?2.

In the fourth test case, it is impossible to divide three identical candies between two people.

In the fifth test case, any division will also be unfair.

這里面說的是分糖果的問題,就是有2種糖果,1種對應(yīng)的大小是1,另一種對應(yīng)的是2,其中2的糖果不能分割,那么求出來如果按照這種給定的糖果數(shù)量,能不能將他們平均分配呢?

1:放到map中。1跟2分別對應(yīng)的數(shù)量;

2:如果2*a+1*b是奇數(shù),那么肯定不能分配;

3:如果是偶數(shù),那么就要看a跟b的數(shù)字是否是偶數(shù);

3.1a 跟b都是偶數(shù),肯定可以;

3.2 a是奇數(shù),b是偶數(shù)的話,也是可以的,但是b要大于等于2才行;

其他情況就不能平均分配了。

以上是思路,下面是代碼:


CF:Fair Division的評論 (共 條)

分享到微博請遵守國家法律
普兰县| 四平市| 金川县| 武冈市| 绵竹市| 榆中县| 宝清县| 尤溪县| 奇台县| 怀宁县| 木里| 阿鲁科尔沁旗| 通河县| 江川县| 轮台县| 秀山| 温泉县| 渝中区| 拉孜县| 花莲市| 扎兰屯市| 济源市| 十堰市| 聊城市| 邵东县| 隆化县| 岳普湖县| 大理市| 水城县| 平阴县| 大方县| 佛山市| 邵武市| 洪泽县| 屏南县| 原阳县| 河北区| 康定县| 五家渠市| 岱山县| 句容市|