CT56641

Last ribbons of Dorian

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the temple city of Sunspire pays by the answer, and Dorian intends to earn it. First: the full register of ribbons. 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 <= 2342; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1394 1196 266582043 242078696 390509488 853812214 761527701 290813282 546711991 417361756 63862693 5134874 231778049 545836272 937411286 51231557 509192075 496408092 364849923 599574310 917312447 617503670 371688670 660649427 796530654 320709829 976340857 349498693 543330261 773280155 903184222 977284489 910468214 591303478 79947391 91233251 726554836 555413656 234640038 957879537 609118774 910992596 423765976 880430280 489545340 328864377 68141634 63899406 731211467 796093406 562101679 919507291 388926750 261559502 350519588 971263684 578306342 850120807 883894428 467893491 715193899 236234952 204703029 218811291 679566448 199105203 786381281 632132275 475454547 908544128 829181342 505730760 466132354 578264957 655454319 148280580 911541369 446287999 675948170 667791767 176096621 50292379…
Output: 602495538901

Example 2:

Input: 2308 594 657354533 695128794 884516011 263113571 248235785 495577304 452189024 250283598 632681924 964166469 24842951 47346288 315060445 217749052 682878905 952882466 916248204 206081738 123940663 10728302 189612522 398899166 532177465 160597336 223580748 24418068 701852886 867390466 694770697 500552384 986318850 72877095 609338458 245789086 196956773 187423722 980969253 125292312 347757479 827019909 401926125 92694046 925238469 3879228 305090373 865209530 910582907 716986783 136599112 250605116 768510064 516185446 658142044 488440453 615034869 575571971 907786328 478737923 417113915 15285938 412944664 43664540 726307041 53919176 680703412 385429731 219468384 237459574 600554499 633919193 977624102 509111908 813854890 652104246 384321961 304339066 640962594 323062884 793536388 702353285 16…
Output: 318373590144

Example 3:

Input: 2020 675 379858999 576558979 599482972 197606226 234491230 972262454 533300248 993519997 707132900 262769175 216744398 827985808 743744302 180942044 820112637 702406689 213308403 714238670 158876851 152132481 9685403 690846683 335537350 364452227 567606940 231599932 581221800 862179727 538805250 738843239 781790082 34770797 916755765 840626554 359060704 816768948 617537514 165381103 60850878 152225322 708430893 549443586 233955020 783635424 832434765 914012054 498194794 66174997 210857684 151674755 962722135 964741591 570892766 136389752 758980951 241888301 924417117 426551744 879042596 414937773 988520368 68889946 164626255 331052031 786581619 219264479 790999108 112795590 138165822 309427213 343710385 544918474 558171344 241857867 875757602 141365797 729746682 869137683 626880471 8493769…
Output: 354918227863

Constraints:

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

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