Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2016-12-16 14:23:57
use scanf and printf |
||||||||||||||
2016-11-16 04:19:42
just sort ,count & break with simple array !!! :) |
||||||||||||||
2016-10-09 21:56:14
Seems kinda hard for C#... used Dictionary with as much short-circuiting as possible (when adding all that remains won't even suffice, and immediately when we've gotten enough), and I get ACs and TLEs across identical submissions. (0.5s is the time limit I guess, I don't understand why the problem says 0.178s--can someone explain?). Got about a 20% speedup using the standard way, but didn't think of it on my own. |
||||||||||||||
2016-08-23 18:57:40
My 50th in spoj :) :) |
||||||||||||||
2016-08-19 11:47:13
sort array |
||||||||||||||
2016-03-23 19:50:10
use scanf/printf for ac or std:ios::sync_with_stdio(false)l |
||||||||||||||
2016-02-25 21:34:02
a bit tricky language ... |
||||||||||||||
2016-02-19 16:16:00
time limit so much harsh for JAVA |
||||||||||||||
2015-12-07 14:36:33
using only simple arrays did the trick......AC in 1st go:) |
||||||||||||||
2015-11-15 12:54:32 sumit suthar
c++ map :) |