Equal Parity
Practice
3.5 (10 votes)
Linear search
Algorithms
Greedy algorithm
Problem
52% Success 3448 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array A containing \(2 \cdot N\) inetegers. You want to obtain exactly \(N\) even integers in the array. Is it possible to achieve the goal using the following operation any number of times(possibly zero) ? 

  • Choose two distinct indices \(i, \; j \;(1 \le i, j \le N, i\neq j )\) such that \(A_i\) is an even integer, then set \(A_i = \frac{A_i}{2} ,\; A_j = A_j \cdot 2\)

 Input format

  • The first line contains denoting the number of test cases. The description of T test cases is as follows:
  • For each test case:
    • The first line contains an integer \(N\) where \(2 \cdot N\) denotes size of array A.
    • The second line contains \(2\cdot N\) space-separated integers \(A_1, A_2, \dots, A_{2\cdot N}\) - denoting the elements of A.

Output format

For each test case, print "YES" (without quotes) if it is possible to achieve the goal and "NO" (without quotes) otherwise.

Constraints

\(1 \leq T \leq 10^4 \\ 1 \leq N \leq 10^5\\ \\1\leq A_i \leq 10^9\)

The sum of  \(N\) over all test cases does not exceed \(2 \cdot 10^5\).

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
125 votes
Tags:
AlgorithmsEasySearching
Points:20
175 votes
Tags:
Ad-HocEasy
Points:20
32 votes
Tags:
AlgorithmsLinear SearchGreedy algorithm