CT47862

Scribe's Windward windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the zephyr cliffs of Galeholm opens only for a perfect tally of windows. Scribe means to find out. 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 <= 3338; 1 <= a[i] <= 1000000.

Example 1:

Input: 701 311 614127 697104 306255 748519 978204 993005 934749 634907 23101 17969 170305 923147 383317 513110 892110 28871 95425 545788 955420 893620 974562 374692 665406 553383 955572 269822 128405 613476 268908 755837 562884 590339 982587 64766 259613 737183 224295 581409 644375 442644 397011 597444 734656 386832 516430 256826 593481 14079 493629 333299 807374 161792 983630 568296 8326 430999 819087 986516 754978 215271 727458 99661 878156 846159 325325 466133 61568 769916 688088 218631 173797 732156 655448 474309 239721 993911 777001 171698 738325 873569 239735 820950 91850 683064 812113 752680 303808 983176 886399 991924 510384 160227 828377 57536 501929 641021 205154 652241 994952 424259 474737 929129 884405 100848 178854 116139 169732 679610 727026 233693 199712 899760 55659 566987 419482 …
Output: 162065363

Example 2:

Input: 3293 684 628344 927186 145584 728509 625423 587250 547049 382507 223368 260493 458959 417938 615850 901330 480001 701021 486452 934464 52740 111925 459703 438053 876986 518551 440161 829363 741179 773860 413755 628178 536197 614762 764456 986525 435060 722871 960615 649575 788273 800709 660051 548780 679031 800073 56145 185721 179592 452788 921765 846630 987397 770489 612144 562324 255728 694712 662982 354924 797063 52819 505630 346842 197400 889538 111758 727917 717719 362279 25158 583267 750506 699090 937940 269594 613927 464316 979890 990242 557374 354556 660236 600574 770104 743208 445146 800840 432513 389053 869748 773976 83281 188950 964798 836320 106726 876646 377007 341906 917837 729952 969303 836811 324007 578090 458280 905941 751551 66490 395613 974786 832597 899204 332359 724492…
Output: 355368900

Example 3:

Input: 2869 358 169281 306581 415159 384234 916392 59013 325357 559035 134671 680586 859400 768687 324900 271584 47338 730980 494236 461371 624367 465518 225357 561771 348852 725244 466056 805256 444102 146227 880189 669731 260661 407982 750892 714563 580704 100780 645182 675313 413027 247620 734928 965995 645706 269424 462581 343893 182976 921238 188198 770054 392405 42745 181802 997733 689934 416065 421649 273439 317562 966144 947383 350391 529452 353154 136740 708886 154249 234592 67432 536491 733051 695484 48000 465080 381982 323937 668401 101156 750937 274765 958300 444259 469327 913914 817156 376468 38785 149126 386371 381688 725526 711291 866883 823496 407464 538516 401840 554418 160758 809570 364530 284663 429620 419762 739986 616547 864215 311561 610943 776435 11930 287198 283623 972306 …
Output: 192359548

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Scribe's Windward windows - MEDIUM Coding Problem | CodeTikki