Equal Average

All submissions for this problem are available.
### Read problem statements in [Hindi](http://www.codechef.com/download/translated/LTIME75/hindi/EQAVG.pdf), [Bengali](http://www.codechef.com/download/translated/LTIME75/bengali/EQAVG.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/LTIME75/mandarin/EQAVG.pdf), [Russian](http://www.codechef.com/download/translated/LTIME75/russian/EQAVG.pdf), and [Vietnamese](http://www.codechef.com/download/translated/LTIME75/vietnamese/EQAVG.pdf) as well. You are given a sequence $A_1, A_2, \ldots, A_N$ and an integer $K$. Determine if it is possible to reorder the elements of the sequence $A$ into a sequence $B_1, B_2, \ldots, B_N$ and choose a real number $m$ in such a way that for each contiguous subsequence of $B$ with length $K$, the arithmetic average of the elements of this subsequence is $m$. If it is possible, find one such reordered subsequence $B$. ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains two spaceseparated integers $N$ and $K$.  The second line contains $N$ spaceseparated integers $A_1, A_2, \ldots, A_N$. ### Output For each test case, print a single line containing the string `"YES"` if it is possible to reorder the elements of $A$ in the required way, or `"NO"` otherwise. If it is possible, print a second line containing $N$ spaceseparated integers $B_1, B_2, \ldots, B_N$. If there are multiple solutions, you may print any one. ### Constraints  $1 \le T \le 1,000$  $1 \le K \le N \le 10^5$  $1 \le A_i \le 10^6$  the sum of $N$ over all test cases does not exceed $10^6$ ### Subtasks **Subtask #1 (40 points):**  $N \le 1,000$  the sum of $N$ over all test cases does not exceed $10,000$ **Subtask #2 (60 points):** original constraints ### Example Input ``` 2 5 3 1 1 2 2 3 6 2 1 1 1 1 1 2 ``` ### Example Output ``` YES 1 2 3 1 2 NO ```Author:  kingofnumbers 
Editorial  https://discuss.codechef.com/problems/EQAVG 
Tags  easymedium, implementation, kingofnumbers, ltime75, maths, taran_1407 
Date Added:  27082019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, 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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions