MAJOR - Majority

The human tribe has just discovered some other tribe and wants to communicate with them. To make sure it is not intercepted by the terminators, they ask their chief computer engineer Rohit to design a system for the purpose. In the design that Rohit proposes, data is transmitted n times. If it is received more than half-the times, it is said to be successfully transmitted. If not, the data is said to be lost. Rohit obviously got a lot of fame and respect for his work. Nitish doesn’t like it and wants to challenge Rohit’s supremacy. He wants to check out the system and has hired you for the process.

Input

The first line of the input contains test cases t (1 <= t <= 100). It is followed by 2*t lines, 2 for each test case. The first line of input for each test case contains a number n (0 <= n <= 106), followed by n elements in the next line. Each number is from -10^3 to +10^3

Output

You are required to output ‘YES’ followed by the number transmitted, if it was transmitted successfully, and ‘NO’ otherwise.

Example

Input:
3
4
2 1 2 2
6
1 1 1 2 2 2
5
1 2 4 5 1

Output:
YES 2
NO
NO

Added by:Troika::Bytes
Date:2010-02-18
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: PERL6

hide comments
2013-08-10 09:26:54 pm
got AC in 1st attempt !!
2013-06-20 09:45:14 No_words
Note for Java Coders :

Scanner will not work. Even BufferedReader wont work. You ll get TLE. :|

Use highly optimized IO ! :)
2013-06-19 21:40:47 Vipul Pandey
Simple, easy and a nice one for beginners!
2013-03-06 20:07:56 R.VIGNESH
easy one..


Last edit: 2013-03-06 20:11:21
2013-02-06 18:55:39 Abhishek Sen
Can someone please comment on the range of numbers being accepted.. I have taken it from -1000 to 1000.. but getting segmentatn error while using an array for the solution.. Is my range right?
2012-12-31 06:28:40 ritz
nice problem :)
2012-12-30 09:34:54 Anjaan
always think what u have to got from an array........... think ///
2012-12-27 19:34:00 Yo Yo Honey Singh
TLE while using cin...
Wrong ans... while using... scanf...!!!!

Last edit: 2012-12-27 19:34:34
2012-12-22 10:19:28 Beqa Aivazashvili
it is not very easy
2012-12-17 18:35:10 Anandababu
Any problem of complexity O(N) requires us to optimize extensively. I submitted the exact same solution in Java and C++. Got AC in C++ but TLE in Java
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.