Strange Problems

All submissions for this problem are available.
Agarwal has a habit of creating Ajeeb Samasya as usual and Shubham always comes to his rescue. This is time he has created another samasya which is as follows. Read carefully! Shubham has an array of $N$ integers and an integer $K$. He wants to create a subsequence of this array with some conditions applied. He builds $ceil(N/K)$ blocks of this array with size of each block as [$i * K + 1$,min($(i + 1) * k,N$)] for $0 \leq i \leq N/K$. For two consecutive integers in this subsequence, he wants the integers to be of two different blocks. (It is not a compulsion to have one integer from each block). Also, lets say the indexes of any two integers of this subsequence be $i$ and $j$, then he wants $i  j$ != $K$. Shubham takes the sum of integers in the subsequence. He wonders what can be the maximum sum obtained? Help shubham in this samasya. ###Input: First line contains $T$ : number of testcases For each testcase: First line contains two space separated integers : $N$ and $K$ Second line contains $N$ space separated integers : $A_1$, $A_2$,..., $A_N$ ###Output: For each testcase, print a single integer describing maximum sum that can be obtained. ###Constraints  $1 \leq T \leq 10$  $1 \leq N \leq 2 * 10^6$  $1 \leq K \leq N$  $10^9 \leq A_i \leq 10^9$ ###Sample Input: 2 3 2 30 10 25 6 5 5 4 3 2 1 1 ###Sample Output: 35 5Author:  buzz_95 
Tags  buzz_95 
Date Added:  15082019 
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