CT29038

Zaid Counts the scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Zaid the measurer watches over the lily shoals of Padmore's stores of scrolls. A careful computation stands between order and chaos. Task: Print the maximum sum of any contiguous subarray of length exactly k. Input format: First line: n and k. Second line: n integers. Output format: Print the maximum window sum. Constraints: 1 <= k <= n <= 1205; 0 <= a[i] <= 1000000.

Example 1:

Input: 490 46 132802 678138 8636 67480 391068 272064 20715 527518 169583 770310 534828 687785 64603 285198 370610 191761 626402 81391 422888 618595 17677 973211 295612 804171 345291 378315 361607 195940 376964 192589 782846 103624 392370 274427 857610 935013 945332 457827 633040 291777 74425 903276 914986 985996 106938 234082 828096 283356 623470 481013 659736 709963 302787 482320 251133 120845 872570 522762 687729 505819 998711 65873 31837 985787 57277 519841 744192 92422 552380 277918 60997 804260 330152 121434 362017 144282 22582 504730 282517 534468 839909 786842 163404 143457 495610 210946 615649 654757 781361 651818 502638 651018 262568 690653 981552 159803 560482 964216 284657 559839 987250 862927 556751 789181 613229 118591 165844 53104 539196 31460 655083 387179 460582 120067 176063 1778…
Output: 26377563

Example 2:

Input: 406 366 845483 552720 801725 104976 629593 466438 501853 221854 106095 356562 656271 654528 602885 688799 713198 15936 28605 580470 975696 213290 718285 169626 115792 416902 974412 731284 759544 988300 967392 584217 427006 419716 560066 449246 529905 201290 201019 822537 664394 977412 269707 887961 138448 513763 678575 634284 194901 611947 72132 707932 300625 118711 40724 580127 941482 200659 940215 992992 244474 384224 502122 922376 87389 994009 360434 402887 711795 941049 827058 149970 894855 790210 298225 57109 393196 377047 123439 930036 352092 997701 426210 932383 970065 29261 751811 551505 307850 729771 623180 663067 769274 376982 817102 742806 785890 443556 916918 259116 345942 501881 838344 856623 909279 430666 896650 711109 234290 462221 115348 521013 9022 969349 647399 317637 387…
Output: 187936878

Example 3:

Input: 664 348 381051 539464 990724 112545 377488 66174 113377 11431 291561 394616 316567 329582 652799 271634 925333 628830 982251 653289 260849 707134 460063 785805 196546 475893 437175 864069 324806 919990 492930 757822 745230 138097 548380 135346 913718 960068 363225 65407 536941 340245 613362 72259 247890 921555 986768 850497 143936 558759 463240 213899 585368 577182 715580 397506 14630 102784 991549 988791 15198 91617 636264 731691 226835 471 131463 871200 851717 748112 94313 218010 111001 164772 925868 405188 455087 65504 330903 171330 620165 175763 208530 821195 891428 671545 202413 875307 353068 939503 180700 670243 983544 985425 888419 860265 643698 481659 189620 79954 601911 533583 426838 784507 53546 467735 441949 120341 981290 360742 259201 875485 722366 277261 472604 207848 22373 30…
Output: 171404781

Constraints:

1 <= k <= n <= 1205; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Zaid Counts the scrolls - MEDIUM Coding Problem | CodeTikki