MAJOR - Majority

no tags 

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

hide comments
The Bartender: 2011-05-12 18:36:25

@Radhika: Nope!

(Suppose it's possible)
Length of transmission: T
Two numbers a and b transmitted: t times a, t' times b.
t > T/2 and t' > T/2 => t+t' > T

But t+t' <= T (Length of transmission)
Contradiction!

Radhika: 2011-05-12 17:02:43

can more than one number be transmitted successfully??

vijay: 2011-04-08 10:47:26

@saurabh
Problem gives recieved input and if any no. appears more than half times , it is transmitted successfully

saurabh kumar jha: 2011-03-24 07:04:04

can anybody explain me the prob...how to decide whether the data has been received or not???

anksanu: 2011-03-07 02:29:29

the same code givin tle first and AC later
took my 8 submissions :(

Badr: 2011-02-23 00:29:14

@Radhakrishnan yes its easy but not as tutorial ones

Gaurav: 2011-02-22 20:26:20

use scanf and printf instead of cout and cin....

Radhakrishnan Venkataramani: 2011-02-14 16:46:02

can u move this to tutorial ?
This s basic problem :)

snapDragon: 2011-02-14 13:25:21

I am getting a TLE . Can anyone help me with this problem . it's a O(n) solution


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