CT49679

The Ember scrolls of Rhea

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the tundra station of Whitesnow, Rhea records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1603; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1600 441 28854972 595193358 869668035 178635290 314727703 902746025 249463471 645200067 942672569 201469540 900649618 715388322 334570787 244048885 758835332 175747109 721518089 979970626 301399753 232295006 199160731 787934154 969670371 91820812 703069953 505351048 980588989 778631310 168358318 132984536 485158833 600544778 11023822 250790297 29769410 16950148 119973670 192210035 420206510 271070108 386353164 910511960 684151519 664450979 433340406 100180589 986215051 934886500 995307265 452519487 545453953 935310068 486951848 943660789 500043086 704339123 774566594 849806575 555623249 363208032 21682511 551945883 723552994 477885476 162303279 769985156 559546606 891257386 929414541 436009314 620223545 745086434 138930264 665710670 302094298 549144682 182120029 222501350 113751895 6870812…
Output: 228252213751

Example 2:

Input: 352 180 664593500 875209085 307351203 777904218 613170270 851686292 56806395 605880162 62494286 490157511 720801883 576447909 552714522 842083052 552164668 463431817 629951709 305210239 624700143 8695981 794663018 515675721 901167441 653682315 993972284 33249036 729381002 124308185 996304309 496904409 95299057 981704962 869601430 333306235 694240081 242434620 624710678 667077981 826254930 851967354 183281223 116716594 717400046 690524144 408194935 515298513 99312409 745955307 960469154 836676914 238975860 824632965 608509899 225369451 377712025 973600806 443945122 636222524 285571568 415557751 488897129 334401551 944061320 489130342 493964911 463710298 65304356 342317795 649331271 603723484 157401466 675160673 468884996 487597545 858355231 846798361 952324500 203543387 863462082 13441656 2…
Output: 90039730758

Example 3:

Input: 54 33 208061718 156626335 992954178 678238670 665193003 749221698 4670345 861575245 253652800 282384183 341857544 433322102 420972496 280599048 395626061 532695507 813889509 221057965 353134840 454494090 19102301 963783159 395396456 368024082 96002519 857905465 361017381 212967523 267446834 361933818 407052462 480558198 745056309 592369436 489562789 559537665 403281941 660079263 153091616 385297099 302344558 324383886 86281697 515319270 118781617 272593136 677909709 200159460 271133812 676903733 985469484 853412850 363178265 498311236
Output: 15353718016

Constraints:

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

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