CT36187

Paige's Ivory Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the ivory gates of Alabast, Paige the valuer keeps careful count of the panels. optimize the storeroom layout, every figure matters. 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 <= 1859; 1 <= a[i] <= 1000.

Example 1:

Input: 358 285 846 222 440 654 770 975 28 470 371 904 999 486 669 749 546 711 135 320 99 46 474 109 336 733 420 582 481 325 145 164 998 387 491 957 505 22 719 914 1 794 812 162 760 328 644 656 226 750 325 862 320 207 486 175 232 889 443 311 881 870 433 120 724 581 733 19 604 334 190 737 39 234 424 368 285 624 203 785 943 417 920 31 513 813 570 46 196 338 433 170 533 999 241 995 666 649 501 781 930 895 707 590 873 310 100 155 330 76 733 581 161 988 590 665 378 694 25 850 138 684 261 485 872 983 86 362 129 859 449 548 821 185 256 461 223 264 698 576 220 598 746 569 934 833 963 405 870 1000 482 310 150 700 58 464 367 452 527 36 780 861 783 907 283 496 269 889 957 485 75 196 283 420 795 886 339 919 683 687 325 517 145 991 298 565 50 313 987 803 478 416 77 725 85 769 514 694 700 973 720 925 891 125 93…
Output: 149703

Example 2:

Input: 704 293 329 396 1 794 112 873 479 30 415 831 591 600 570 464 143 770 372 705 51 82 425 929 587 910 469 55 82 234 763 799 709 266 358 144 522 15 503 519 521 508 84 274 865 189 962 975 381 845 213 615 22 674 510 428 376 517 761 452 90 788 282 669 423 906 822 849 586 768 516 934 629 778 749 44 753 32 869 853 259 67 257 775 761 472 35 930 954 925 658 946 3 938 330 130 864 901 517 265 756 328 803 477 543 815 426 943 145 722 819 346 182 595 714 178 169 458 125 238 65 117 753 251 712 358 618 774 1000 554 435 323 939 417 912 135 527 109 902 330 392 96 383 907 228 492 183 98 599 209 636 535 963 14 702 96 476 344 36 767 196 414 667 242 411 552 30 787 317 797 367 879 512 818 434 57 308 951 88 929 576 646 867 850 21 583 291 385 735 809 431 421 109 585 439 222 651 828 560 283 846 914 58 229 689 357 21 …
Output: 154626

Example 3:

Input: 1729 1702 756 104 436 717 797 339 134 139 877 773 455 300 881 42 851 892 252 375 560 407 13 62 373 113 845 765 773 697 311 950 270 966 293 225 943 59 235 849 203 73 140 107 439 899 329 903 210 274 877 583 314 660 402 143 412 725 215 379 570 53 883 17 753 577 228 708 550 957 350 338 179 169 901 760 723 551 328 602 645 308 881 727 747 206 610 31 811 887 393 489 985 677 993 521 29 323 466 481 276 767 327 790 427 10 788 782 169 890 198 958 169 657 414 326 124 505 18 774 551 88 772 809 270 821 898 567 595 602 303 450 493 857 391 792 485 167 615 539 317 946 341 665 442 605 915 746 221 583 673 984 588 575 625 285 364 585 186 962 383 393 847 917 422 128 78 467 726 98 157 991 708 21 473 915 337 267 353 354 562 493 975 462 716 375 618 118 705 469 416 443 146 250 267 994 957 976 120 812 6 954 351 189…
Output: 838139

Constraints:

1 <= k <= n <= 1859; 1 <= a[i] <= 1000.

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