CT54315

Nora's Zigzag stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the poppy fields of Scarlet Plain; Nora weighs the day's stretches manifests and starts the calculations. 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 <= 1982; 1 <= a[i] <= 1000000.

Example 1:

Input: 1614 904 383563 803864 996212 963609 534605 466928 854577 315296 652840 902922 505427 577364 95473 245643 820445 118045 954312 583096 373353 757272 852011 561035 990538 126870 778190 857979 46334 773705 179679 254475 13678 324389 696838 949938 890571 752724 212850 639138 94061 532760 550787 115972 853154 505994 50685 389205 352036 367450 348946 312780 636594 934991 879482 788220 199807 884970 272783 533036 785785 384513 144598 171586 366610 135649 167766 694208 367839 285664 321918 772499 721642 348861 126612 162948 392820 939828 874021 866624 950707 908810 624118 838254 795713 667284 817405 389215 178066 463555 853525 540444 121454 84884 135783 591256 298539 59673 840914 801362 495245 909065 405342 279768 318799 568800 732638 500600 295360 884026 870369 51734 666939 770607 957638 838586 3…
Output: 466986061

Example 2:

Input: 211 205 696178 715475 163795 840172 177535 89367 539761 583830 356463 720558 138477 644580 228576 364858 323488 352588 443652 834223 916967 430564 479650 360945 405724 317929 100954 304845 920604 695001 573797 981813 846030 751438 875922 946247 737471 970767 233122 478062 863567 955769 698138 618991 863205 548396 373444 320051 627938 44272 778975 991639 808245 54063 983364 588858 233625 986788 431082 541569 986189 889330 593252 812926 737685 604125 215428 669060 53547 210549 803207 410277 480947 611699 774813 443244 25569 211141 331068 155737 389825 272552 176636 133745 952383 939970 885727 190093 918210 453273 522941 68013 7680 944130 597147 736898 851572 992361 477491 221009 14675 448640 95818 122122 880567 735484 705877 489219 720272 6323 586086 176105 906160 328590 268710 518379 515807…
Output: 106192875

Example 3:

Input: 584 343 732497 303146 239203 742591 874385 908274 804469 742972 596428 991956 471654 305675 115977 239061 76623 418140 719378 806202 18511 810678 577593 453845 247874 942972 209947 794302 491158 296215 510723 116316 705376 840422 718105 713892 31859 642754 242272 473079 70426 367075 370412 511278 843362 766268 121917 269813 459000 751779 675199 475721 10160 286313 426863 775290 727661 920539 728485 81183 169666 767253 317202 223233 531264 324910 534236 915067 121568 865459 86117 798751 803187 629906 699940 576673 638320 650405 341960 222344 835494 297499 250038 207662 285590 396590 153952 987798 405889 606231 187266 975700 47626 49023 150434 645450 603704 662076 926444 65019 520972 634318 779247 930828 940549 172214 578062 759428 412281 683585 635992 284037 550412 738299 783525 268096 1247…
Output: 178151843

Constraints:

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

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