CT36988

Freya's Hidden segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the gristmill of Rye Hollow. Freya spreads the segments records across the table and picks up a sharp pencil. 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 <= 3162; 0 <= a[i] <= 1000000.

Example 1:

Input: 2548 2112 484033 149281 685161 156038 467233 225695 583001 427678 623846 191193 536936 186126 398178 645642 514030 659823 79456 882974 43048 206624 443670 902461 662851 532500 442051 181349 461342 110024 351310 261962 181509 48518 820929 835790 560479 867290 785732 301393 598412 994136 242882 764189 97310 280873 246420 613930 502982 662432 186706 962699 607297 236419 828342 995333 205236 543260 238818 863152 153325 387203 604604 55848 12839 957828 593319 268608 477338 965052 20796 25631 332567 580467 850720 979899 601304 755746 255009 782438 614369 792480 797834 103075 631070 123567 368589 713331 946126 186359 983347 892156 175515 449928 833430 843849 160360 499789 758663 88990 319373 494008 11970 369695 250463 397163 919232 658963 898269 53634 24337 760188 652897 523262 584407 545255 5968…
Output: 1068951269

Example 2:

Input: 3033 273 644186 129429 700314 180868 997674 188444 841473 760496 961869 402502 496236 374032 319547 128401 622634 367721 293110 163541 490842 58630 236017 66982 58665 225495 446961 810648 492621 729716 863324 337414 378072 642143 332217 581208 53200 487536 681814 652184 739013 521697 651487 930504 483779 476175 356627 938872 701836 405824 481191 126582 423315 907658 55042 306590 911416 815803 431822 237117 417927 149889 341618 578550 53552 654386 670341 219827 21946 725778 987646 788421 603425 439580 65096 348764 910491 146281 267041 140291 675738 581256 837501 361057 866385 146310 208193 327265 81931 698596 832834 339482 555237 633572 533255 211228 409126 705422 56925 137301 528832 52761 402796 389053 945478 928627 685643 487081 609239 347571 426263 764324 2123 609271 233867 836217 850146…
Output: 145758102

Example 3:

Input: 1520 241 13622 186920 516246 108510 39562 832579 343678 709706 433587 878714 217263 676271 969419 525646 8881 141483 751259 477887 112286 45139 760001 995659 337857 687645 194994 521562 697196 581513 359443 721779 886050 456730 321634 409417 628785 507484 907512 212576 63412 133444 953181 994549 119639 555457 160411 265057 959716 410023 438444 315185 394293 826645 202956 7180 469803 224233 682671 4823 434 318389 325279 944594 190638 348727 392515 567785 64932 152675 109933 540064 527896 607439 393693 464119 482422 676484 751463 723527 659526 157606 306160 585198 271682 292677 229391 548126 494229 498142 161362 898695 900140 860402 694824 590672 43231 802148 805504 906415 52783 803769 882965 151354 214890 17145 51609 162687 70925 279465 645499 883156 426685 845192 895255 857325 174172 94347…
Output: 128801402

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.