CF1399A.Remove Smallest

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given the array aa consisting of nn positive (greater than zero) integers.

In one move, you can choose two indices ii and jj ( iji \ne j ) such that the absolute difference between aia_i and aja_j is no more than one ( aiaj1|a_i - a_j| \le 1 ) and remove the smallest of these two elements. If two elements are equal, you can remove any of them (but exactly one).

Your task is to find if it is possible to obtain the array consisting of only one element using several (possibly, zero) such moves or not.

You have to answer tt independent test cases.

输入格式

The first line of the input contains one integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then tt test cases follow.

The first line of the test case contains one integer nn ( 1n501 \le n \le 50 ) — the length of aa . The second line of the test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1001 \le a_i \le 100 ), where aia_i is the ii -th element of aa .

输出格式

For each test case, print the answer: "YES" if it is possible to obtain the array consisting of only one element using several (possibly, zero) moves described in the problem statement, or "NO" otherwise.

输入输出样例

  • 输入#1

    5
    3
    1 2 2
    4
    5 5 5 5
    3
    1 2 4
    4
    1 3 4 4
    1
    100

    输出#1

    YES
    YES
    NO
    NO
    YES

说明/提示

In the first test case of the example, we can perform the following sequence of moves:

  • choose i=1i=1 and j=3j=3 and remove aia_i (so aa becomes [2;2][2; 2] );
  • choose i=1i=1 and j=2j=2 and remove aja_j (so aa becomes [2][2] ).

In the second test case of the example, we can choose any possible ii and jj any move and it doesn't matter which element we remove.

In the third test case of the example, there is no way to get rid of 22 and 44 .

首页