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
2015-11-05 07:18:00
ranking algo ;) AC 1 go
2015-09-25 21:38:50
my own algo worked effictively.....Done it in O(n).
2015-09-11 11:22:38 thirupathireddy
there is space between YES and the number................:)
2015-09-06 19:39:45 Harsh Vardhan Ladha
AC in one go!
used cin, cout, maps.. :p
2015-09-01 23:21:25 sneh sajal
can be done without stl..index shifting and array can do d job :)
2015-09-01 12:22:04
O(n) :D
2015-08-27 10:02:59
use scanf & printf must
2015-08-19 20:39:22 richhiey_1996
Solved using simple array. AC in one go after quite sometime :D
2015-08-18 21:08:45
Use long long int and Maps along with printf() and scanf() easy one.... :)

Last edit: 2015-08-18 21:09:16
2015-08-18 10:26:16 dev
done it in o(n) got tle using cin cout changed them to scanf printf got AC ! :D
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.