Beautiful Partitions

All submissions for this problem are available.
Sidaga calls a sequence *beautiful* if the sum of elements of this sequence is strictly positive. Kaspers gave Sidaga a sequence $A_1, A_2, \ldots, A_N$ and asked him to partition it into exactly $K$ nonempty **contiguous** subsequences such that each element of $A$ belongs to exactly one subsequence and all $K$ subsequences are beautiful. Sidaga is getting ready for his wedding  he is busy learning how to dance, so he cannot solve this problem. Can you help him? ### 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 partition $A$ into $K$ contiguous subsequences or `"NO"` otherwise. If it is possible to partition $A$, print a second line containing $K$ spaceseparated integers $B_1, B_2, \ldots, B_K$ denoting the sizes of the subsequences, where $1 \le B_i$ for each valid $i$ and $B_1 + B_2 + \ldots + B_K = N$. The first $B_1$ elements of $A$ belong to the first subsequence, the next $B_2$ elements belong to the second subsequence and so on. If there is more than one solution, you may print any one. ### Constraints  $1 \le T \le 1,000$  $1 \le K \le N \le 5 \cdot 10^5$  $0 \le A_i \le 10^9$ for each valid $i$  the sum of $N$ over all test cases does not exceed $5 \cdot 10^5$ ### Example Input ``` 2 4 2 2 1 1 3 2 2 1 1 ``` ### Example Output ``` YES 1 3 NO ``` ### Explanation **Example case 1:** In first case, there are more than one options. Another such valid option is {2,2}. In second case, it is not possible.Author:  teja349 
Tags  teja349 
Date Added:  12102019 
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
HELP
If you are still having problems, see a sample solution here. 