CT37407

Sailor and the Teal windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sailor inherited the ropewalk at the rook towers of Chessfield along with its curious bookkeeping system for windows. Time to make sense of it. 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 <= 1233; 1 <= a[i] <= 1000000.

Example 1:

Input: 1062 497 577738 93109 382710 572612 328936 381081 902121 124444 445753 65605 246913 881067 450838 29266 729762 223348 775628 134944 22020 471530 645897 887569 69418 175432 145993 234217 715472 960316 488496 283782 832219 98055 380585 494316 79168 574061 171465 34755 339512 10681 878819 863408 778763 640121 902485 101681 901047 173534 786067 122351 454929 235516 716964 457536 476433 52158 775485 446303 290064 933649 21493 360652 292265 216126 758422 267714 337708 39283 154921 634585 187488 871785 291836 629407 235598 363564 406005 395216 772835 476032 653557 276077 670355 973721 442602 337384 200464 35550 948153 595596 827547 278815 582426 490338 504279 841303 639623 172470 636535 232654 361070 268633 432482 257801 835170 231579 269183 291333 589763 530068 480164 703410 973361 110990 259152…
Output: 247139682

Example 2:

Input: 348 40 601405 922420 986926 585638 294002 611577 26382 461220 645386 910194 662042 891023 713008 409126 861042 708514 633447 764191 478025 46355 642508 737647 307970 865938 515212 493188 608462 659266 180135 703762 891575 177913 331450 447449 587787 493294 192146 152357 866011 453076 862422 817237 783672 452907 203291 362298 536729 614855 180154 816221 336991 30501 112679 157899 592741 47976 55915 261685 282978 959029 7293 593310 522052 628463 673740 70370 811924 748629 398979 730234 136785 368501 719185 233302 274264 465589 439110 489479 478111 11262 518648 439445 387571 991061 484925 197887 15223 801016 626806 252276 927583 91658 865907 870776 52030 856783 697489 192738 409443 892930 52686 276214 537642 617967 76134 362731 551846 402179 730775 815647 375751 598705 25606 641583 166002 232…
Output: 23347812

Example 3:

Input: 199 2 662043 745227 809418 279420 970275 163459 162645 758450 681302 332690 361184 687509 491857 633799 953550 740664 569055 744015 862587 467587 237428 817293 857158 651893 105594 523731 558182 162081 895029 386202 485828 947109 22392 322453 698603 500901 539009 501637 590934 620634 490086 687798 823783 625322 870354 649088 468786 252466 469373 272347 109092 729094 703315 325071 340939 785903 958663 985264 471667 699493 261103 681608 936606 631836 630900 937354 764353 292970 547541 493567 974932 221262 31533 780672 712095 813537 710623 443541 639611 547713 580852 262699 458897 831657 597715 527685 17959 765807 636566 919634 983949 567597 374370 87674 974587 188901 81688 330200 246686 486352 123948 716161 195076 720207 944861 797954 258255 359557 861542 144193 981749 394129 649344 300147 3…
Output: 1943927

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sailor and the Teal windows - MEDIUM Coding Problem | CodeTikki