CT55914

Paige's Violet windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Paige the inventory keeper watches over the orchard lands of Applerun's stores of windows. 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 <= 1994; 1 <= a[i] <= 1000000000.

Example 1:

Input: 658 130 830307161 343445139 799286963 691138620 342928234 589064823 735837219 112621616 461235924 531489313 300763805 646017936 841370672 387849884 499235023 616473834 909406496 689428036 637292126 906357504 309571420 414686333 822102894 811447287 196211529 868124266 699429879 566339462 430455867 187064724 736848049 141146658 352777166 83450018 771503061 428228617 872391279 459430502 170448810 339648142 170908448 274257045 484110739 690355701 461423351 642567686 328997489 717313297 243158854 896666219 198674219 806736668 139498612 15941239 808337908 552855084 703249046 197208030 291274349 243160286 72656333 56636369 942239141 771928122 460287304 466418551 213653817 751317255 112271396 530177789 74148769 746843366 313434095 596669194 446488613 930902025 144054696 115064838 664120605 9892404…
Output: 74527917699

Example 2:

Input: 1874 1211 614024075 995960400 789913054 210705671 967984991 208291805 444431648 14041043 707927882 563616521 458412320 617139402 968637990 293322684 786825980 660137537 169032450 803896384 39487895 760506867 805705580 894983836 870445185 974025277 795181617 222786146 226586005 83287701 370107250 773466105 683935246 896049159 403647610 501850840 122073727 227938043 340419973 431137568 778180213 494144029 307812766 619469298 601547984 955757206 168551173 230143018 677190324 474058618 185096655 594681539 524554962 733339562 540857004 776490790 322660366 304135560 456410400 190950456 683649755 24157098 354959096 10789593 344554450 547738489 146993650 345241593 563241866 42508138 566787222 185621918 451028919 964666410 730339299 386370679 665632077 808510078 869963910 441854417 133980583 560226…
Output: 603208233303

Example 3:

Input: 147 4 372312753 685057251 277697294 504213253 758813607 428839812 663308571 834155608 770394368 223434080 677046870 731746257 97059471 958516308 696474056 857541405 700426711 773625240 192002056 845857040 84746134 429198230 743622262 691157107 244950024 139458756 4428529 433994159 481048859 129443005 7054382 586465413 257442691 711468887 75749991 672955166 92145280 283538708 948334979 728407279 99110555 43551500 756643416 734623788 970287379 701299279 438965902 706123970 325730418 597024534 911474451 182618670 603516530 407510373 42404965 282209356 216991471 540590226 600445110 288319563 505936265 583918397 981777226 435968866 271231278 924438954 679358601 243258065 811936782 24167324 230069560 301131956 150325378 181999789 183454918 593717375 847220835 230379094 87839864 831140585 2262364…
Output: 3212958480

Constraints:

1 <= k <= n <= 1994; 1 <= a[i] <= 1000000000.

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