CT56605

Cora Counts the stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the saffron fields of Marigold Row, someone must certify the cargo before shipping. This year the task falls to Cora, armed only with the stretches register. 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 <= 2072; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1017 623 393955 249889 178298 695267 223462 -92975 912230 -352834 795082 567006 125072 -277578 -324248 -584964 -906975 89642 -539273 -179943 807327 -418467 57801 454704 -8951 675758 781902 -825565 -217454 -209377 494256 232511 681644 36058 -463653 765351 -161637 -343816 379713 640572 665835 607846 -717187 -310651 475801 -591840 -649995 151609 -689036 839576 -633053 -46361 -385535 303698 117649 790831 823703 470003 104097 -664434 -323429 793440 -87135 474446 -79522 826411 988188 -159720 444719 -27567 -694135 833734 -268205 -760309 521546 -608123 454650 398811 -319699 -30406 -76844 971358 -569592 -397719 475956 219084 91129 -942952 -676375 -782957 -792279 74305 -578658 -813813 73816 219372 -683724 140377 929970 357804 735606 -311763 -654553 -71510 63331 764813 912631 -661112 818139 129231 -7…
Output: -3831499

Example 2:

Input: 1133 486 98686 715686 -235177 273607 101809 -882087 783824 -753074 -175030 -62522 -35366 -254396 -633545 -273507 -817231 968058 440261 -770959 981607 93601 951873 46488 940955 -711576 402754 925826 -151095 -135592 423651 -926271 -530750 -761061 709541 -2189 -150324 855974 -86614 716788 261001 602649 42697 -850350 772984 -746427 -535491 23203 -349769 892541 -290923 -401396 -590821 301321 432114 782846 204660 280630 202485 -523442 499992 -535474 -327929 31761 64136 -279267 -990777 114677 -235448 562157 564558 -540219 364327 854350 -953646 820261 -676654 -104704 -199516 -916100 735114 418104 -123895 318413 -393659 -913600 293201 -943240 818144 -848860 -824983 248443 756207 23410 -321511 72732 93851 109373 -851003 652407 -352475 -512704 -669427 529779 -818213 -524975 179879 201239 270748 -7871…
Output: 7162532

Example 3:

Input: 739 595 -184402 763911 811765 60782 -61042 -194233 -844986 753356 990040 77651 -456096 -236234 -707129 412257 444765 552424 940221 -537470 -887562 745236 827277 -152456 269935 779477 -407139 15505 -723501 570324 747082 -78977 -412385 -782528 537231 162127 915197 519821 44940 -442536 -696138 871811 -730037 -41953 -116171 189694 -840770 -704125 167237 -789700 -251528 -954063 -126572 626001 377099 398451 369962 752789 -112264 852426 -518798 -875135 -460138 426164 -991026 -93225 -382064 495813 119116 -656112 381299 -915637 206829 200730 150011 -482245 -111413 -292840 794729 -839085 597739 668672 745434 893945 -92709 -984122 655356 832084 -126121 647816 -668218 48533 187668 -105217 358389 220894 -359033 951439 27747 -41164 205684 -416963 545174 -593635 355986 822463 59207 695544 -64128 -618792 …
Output: -3405881

Constraints:

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

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