CT41550

The Topaz panels of Dorian

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the railway depot of Cinderline as Dorian unrolls the day's manifest of panels. The tally will decide the next shipment. 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 <= 2507; 0 <= a[i] <= 1000000.

Example 1:

Input: 2050 982 651678 484266 326091 986506 166604 892501 929297 812732 491084 297411 772159 757019 174138 202555 387922 687452 416011 768928 261433 720625 834699 480670 293212 264148 660961 150155 311386 455943 689214 795208 713322 499724 662357 814259 806034 127378 947624 161808 260919 58855 531259 202365 486825 193370 285731 777414 132126 425133 883169 904522 612887 998363 165663 935690 793675 595682 350219 533069 679698 308680 817316 593384 332877 945277 995509 446706 138622 144400 659438 504708 646027 913333 187346 160674 558953 864870 149001 333417 583836 564576 979436 975507 622872 460823 180194 65177 869109 647192 606407 258568 699507 804879 527760 642940 568552 213730 455576 422284 901339 866932 90308 329683 763893 306324 868022 646164 341403 497211 277384 1441 299117 49417 358767 574468…
Output: 495065008

Example 2:

Input: 826 529 547124 256973 390009 89686 921582 285526 156631 662921 703390 401546 557331 701186 126031 512542 460383 36411 94264 654811 805981 384503 209292 384680 178888 736339 827253 905429 353605 509565 972059 275189 400790 761287 974735 737952 474775 92053 380900 917579 261537 539195 894003 502130 841877 716187 940370 823315 291587 134324 252039 505902 907920 902651 980924 387070 368556 618488 548024 595368 846798 24683 265077 177007 205018 711825 892885 623975 518812 862173 851698 810074 359373 683976 596297 322220 653152 748503 857642 487164 67461 760366 307609 892776 403828 387545 373424 222663 313937 105783 167215 149220 659103 769706 591626 934881 962707 779361 959955 161689 525399 27003 972558 611484 873760 680853 334618 383264 938506 545018 816485 878285 300737 811457 597345 990414 6…
Output: 272313216

Example 3:

Input: 2202 596 758966 948474 686303 472187 337742 294578 533434 32035 899516 34228 624405 869603 387790 383133 767590 669835 764618 337754 725493 230912 236572 931750 574920 496665 764349 30726 241328 376834 603847 698726 879176 666011 950133 109178 347086 597585 866308 144051 436988 918051 747589 948124 418124 198642 692029 527806 514334 603349 972051 407887 296251 539951 830087 390054 205778 589634 85814 811286 802360 833558 829056 772826 524144 969343 133372 376757 396449 271363 269807 99320 45315 122823 188628 593744 54361 622765 367296 397100 106465 746423 69541 170055 462133 438426 74374 878601 336384 942322 198248 694851 412007 468778 698151 603047 796827 50242 499594 545169 108176 623359 149586 595542 789193 973887 180042 382743 371844 158139 25165 652179 276820 967442 689280 746530 5474…
Output: 301844203

Constraints:

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

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