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
shantanu tripathi: 2015-08-11 21:18:42

maps + scn&printf ...:)

ASHUTOSH DWIVEDI: 2015-08-05 22:13:44

use printf and scanf instead of cin and cout..

r0bo_dart: 2015-06-22 20:52:32

Damn easy... use Maps.... consider the case for n = 0 as well. Costs me 2 WA.

Rishabh Joshi: 2015-06-13 15:13:13

Was printing YES as soon as some element becomes more than half.. WA.
Checked for max... got AC. Problem setter, please look into this.

Piyush Kumar: 2015-06-12 15:40:20

This should be moved to tutorial.

PRIBAN91: 2015-06-08 09:15:07

Awful problem with awful spacing in input, or at least in the test cases given above! Waste of time and effort!

SRC: 2015-06-04 11:11:52

Can someone explain the testcases? I cannot understand the problem !

Addy: 2015-06-04 00:33:35

Use long long.. got 2 WA's due to it.

Addy: 2015-06-02 15:16:59

What is the meaning of the question? Confused! :/

Bhuvnesh Jain: 2015-05-30 19:56:44

finally AC.. concept was right.. getting WA due to wrong input due to fast i/o (spacing problem)

Last edit: 2015-06-03 14:27:16

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