Jack - The Gentleman
All submissions for this problem are available.
Recently, Jack organized a party where his N girlfriends came. Each of his girlfriend was wearing a colored dress and there are K different color dresses in total. For this party Jack hired a photographer who secretly took photos of his girlfriends. The next morning, Jack decided to upload some photos (as taken by photographer) on Facebook but he uploads only those photos which are "pretty" to gain more number of likes. A photo is said to be "pretty" if more than half of his girlfriends in it are wearing same colored dress. In other words, if there are G girlfriend in the photo, it is pretty if strictly more than G / 2 girlfriends have same colored dress.
Write a program that will check for a set of M pictures if they are pretty, and which color is dominating if they are.
First line contains two integers N number of Girlfriends, K number of Colors.
Second line contains N integers between 1 and K (inclusive) representing color of dresses, ordered the way girlfriends came into the party.
Third line contains M, number of pictures.
Next M lines contain two integers A and B. Each line describes one picture. On it there are all Girlfriend starting from A'th all the way to the B'th.
Output M lines. For each picture output “no” if Jack doesn't think the picture is pretty, and “yes X”, where X is the color dominating on the picture, if He does.
3 ≤ N ≤ 300000
1 ≤ K ≤ 100000
1 ≤ M ≤ 100000
1 ≤ A ≤ B ≤ N
Input: 10 3 1 2 1 2 1 2 3 2 3 3 8 1 2 1 3 1 4 1 5 2 5 2 6 6 9 7 10 Output: no yes 1 no yes 1 no yes 2 no yes 3
|Time Limit:||0.12 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions