P21001 [HackerEarth] In a mystical Land, a person's health and wealth is measured in terms of time(in seconds) left. Suppose a person there has 24x60x60 = 86400 seconds left, then he would live for another 1
普及-
题目描述

In a mystical Land, a person's health and wealth is measured in terms of time(in seconds) left. Suppose a person there has 24x60x60 = 86400 seconds left, then he would live for another 1 day. A person dies when his time left becomes 0. Some time amount can be borrowed from other person, or time banks. Some time amount can also be lend to another person, or can be used to buy things.

Our hero Deadpool, is in critical condition, has very less time left.

Today's the inaugural day of a new time bank. So they are giving away free time amount worth 1000 years.

Bank released N slips, A[1], A[2], .... A[N]. Each slip has a time amount(can be +ve as well as -ve).

A person can pick any number of slips(even none, or all of them, or some of them) out of the N slips. But bank introduced a restriction, they announced one more number K. Restriction is that, if a person picks a slip A[i], then the next slip that he can choose to pick will be A[i+K+1]. It means there should be a difference of atleast K between the indices of slips picked.

Now slip(s) should be picked in such a way that their sum results in maximum positive time amount sum possible with the given restriction.

If you predict the maximum positive sum possible, then you win.

Deadpool has asked for your help. Help him win the lottery, and make it quick!

Input Format:
First line of the test file contains single number T, the number of test cases to follow.
Each test case consists of two lines.
First line contains two numbers N and K , separated by a space. Second line contains the N numbers A[1], A[2] ..... A[N] separated by space.

Output Format:
For every test case, output in a single line the maximum positive sum possible, that is output for the case.

Constraints:
T ≤ 250
N ≤ 10000
-109 ≤ A[i] ≤ 109
0 ≤ K ≤ N-1

SAMPLE INPUT
2
10 1
1 2 -3 -5 4 6 -3 2 -1 2
10 2
1 2 -3 -5 4 6 -3 2 -1 2

SAMPLE OUTPUT
12
10

输入格式

见题面

输出格式

见题面

样例输入
30 16 3 -334 -500 -169 -724 -478 -358 -962 -464 -705 -145 -281 -827 -961 -491 -995 -942 22 2 391 604 902 153 292 382 421 716 718 895 447 726 771 538 869 912 667 299 35 894 703 811 17 5 -673 141 -253 -547 662 -37 723 -529 316 190 288 40 -264 446 -890 370 6 18 2 -629 -84 756 966 -931 -944 -626 -537 118 929 833 -639 704 977 673 21 924 -270 22 19 97 986 161 355 -655 31 350 -941 966 107 7 457 -753 -945 -209 -221 422 506 -413 900 762 -410 19 0 -548 595 602 291 374 596 -348 -668 -281 -53 -418 -900 127 -728 -648 807 310 -813 309 20 0 -600 519 -798 -224 -844 989 195 -93 523 -314 448 -458 580 798 -589 9 472 538 -38 190 23 0 -815 156 -202 272 328 362 -875 869 844 -881 322 -21 557 -892 75 600 -3 -861 -401 -255 2 182 88 22 0 832 -169 -721 -976 368 425 -434 441 145 -718 -139 279 -687 549 -866 193 297 286 488 -455 114 316 21 0 313 -185 -912 832 313 -321 646 -481 196 129 535 173 -44 -292 -253 154 -745 -186 474 -168 787 23 1 202 -477 -314 -334 -372 833 487 518 773 -763 192 102 213 -802 527 -543 23 61 3 -505 725 492 222 19 1 187 -413 270 -235 711 896 285 -140 -695 19 -576 658 371 -678 -851 -18 119 800 60 15 1 170 576 -43 -164 882 565 -577 625 -629 423 902 123 737 195 264 17 1 30 11 411 153 -790 -188 940 -662 -900 -958 365 477 -58 303 -357 -477 113 16 1 -460 -993 405 -111 835 72 823 556 626 526 337 869 896 617 717 585 18 17 229 559 296 53 -584 654 -457 -532 -607 911 -67 -675 223 754 741 459 221 -626 20 19 -850 279 -193 -637 -556 176 -962 881 413 855 142 611 -424 -752 -296 -40 875 818 17 112 24 23 -40 685 -497 990 -353 651 -44 -335 192 264 -503 -775 292 549 561 467 129 -813 601 -215 213 824 -392 -670 22 21 75 498 287 -604 -221 -706 10 489 164 -619 -591 818 750 -975 303 98 -584 -971 913 545 -546 769 24 23 -289 865 -245 318 -601 132 152 -570 -901 423 -600 15 -28 -347 943 -409 49 588 608 -221 -954 146 -949 430 23 5 783 226 -38 -629 -748 359 -766 -955 726 25 -1 -496 -515 342 913 -196 72 -606 -429 705 812 93 36 16 10 256 -936 482 15 230 625 637 690 -662 -893 416 8 -233 -303 303 -148 22 5 28 -80 858 155 -264 -676 909 -561 948 -653 220 923 -369 -259 619 3 -781 392 -313 589 938 410 19 5 -959 -515 -937 58 -971 117 555 -330 -212 -82 85 -484 380 951 -115 -110 -73 977 -956 18 17 -790 -363 -184 200 -885 -71 -867 -295 825 629 -598 693 80 249 -528 864 405 816 21 2 -681 340 21 -721 309 -902 124 745 423 -806 318 907 481 136 -114 84 -290 996 54 -708 491 16 7 958 704 -52 -479 -423 -866 498 196 -633 22 392 925 458 -807 830 -600 24 0 882 315 762 336 418 828 816 449 -658 520 560 162 675 -361 398 714 -188 -638 75 521 -615 234 -905 557 16 5 469 923 333 910 336 -278 -636 164 949 505 4 -623 -970 568 85 373 19 0 396 249 -174 943 -941 419 805 216 -615 64 -893 509 -695 589 -172 358 268 510 -774
样例输出
0 19881 19968 19666 19912 3341650 3745261 3425709 3861569 3548984 2657262 2518951 2180987 2145430 2381826 9956 9985 9990 9987 9994 39692 57476 76240 38924 29904 39577 355335 38704 29223 29336 39702 128578 100572 48076 28946 31979 38773 104987 1328164 76270 36905 29830 29537 29695 1147915 46978 47224 162808 29780 29773 115074 39052 28349 29606 48979 77322 76071 747371 27069 27240 19909 46625 39044 228597 28506 29721 47955 35788 59027 56966 29331 29471 58325 58991 29002 94681 77802 38944 48539 173981 49204 47648 67844 67316 67686 104947 66573 29813 29504 49117 29496 1253932 164504 883508 141426 48680 29503 29603 67241 56403 19909 19954 19878 58501 19860 19842 19950 39280 19322 38939 49417 19900 48899 48130 19839 19646 86819 29401 19661 37629 19552 39446 29701 19886 47664 19900 321436 19956 21723 142083 49265 29789 38952 29532 26185 29409 19909 19634 31808 19911 19967 19897 29705 19969 116918 64580 29706 878873 39693 40885 19718 19931 48024 23279 29538 19690 29701 19864 19803 29416 58996 19925 55330 19902 39366 19960 29922 19695 19906 19843 19739 19894 19966 19804 29957 87932 22039 112510 19697 216072 19729 10367 18234 29263 131010 48573 19939 19844 29633 19857 39388 47530 29520 46201 12782 148336 19911 65801 19783 249384