Elements of the sequence
Practice
5 (2 votes)
Basic programming
Basic math
Math
Implementation
Basics of implementation
Basics of input/output
Problem
91% Success 434 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a sequence of 2N numbers. Check whether it is possible to divide this sequence into pairs such that the sum of numbers in pairs is equal to each other.

Input format

  • The first line contains t denoting the number of test cases.
  • The first line of each test contains the number of 2N numbers (12N100000) in the sequence.
  • Each of the lines contains 2N integers from 1 to 109 denoting the elements of the sequence.

Output format

For each test case on a separate line, print YES if the input sequence can be divided into pairs such that the sums of these pairs are the same. Otherwise, print NO.

Constraints

1t10

12N100000

Sample Input
2
2
99 23 77 1
3
1 10101 2 3 4 5
Sample Output
YES
NO
Explanation

In test 1 answer is YES, because can divided on pairs(99,1) and (23,77).

In test answer is NO, because there is no way to divide so that the sums match.

Code Editor

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Submissions
Please login to view your submissions
Similar Problems
Points:10
Tags:
Basic MathMathC++
Points:10
3 votes
Tags:
Very-Easy
Points:10
28 votes
Tags:
ArraysBasic ProgrammingBasic MathMath
Editorial

Login to unlock the editorial