CT44605

Eklavya and the Gilded stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the honey farms of Buzzwell close for winter, Eklavya must finish the stretches ledger - one figure at a time. 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 <= 3978; 1 <= a[i] <= 1000000.

Example 1:

Input: 2911 1874 683124 515312 815899 557221 178395 16374 250665 855370 182691 325511 651250 904894 841911 928094 357994 614681 23311 583517 467076 351496 270542 353909 328465 655373 809304 842744 732056 33056 745619 915488 964948 775681 866068 615413 123659 44356 534293 683972 844789 99763 224140 474776 748638 256007 739687 666693 97664 140459 879594 418344 591007 36336 426584 867846 360142 554351 964723 245150 230796 369320 221800 840091 336263 210323 53540 709696 472440 457273 594977 168938 391676 732356 390145 832701 992802 830837 365306 402908 356115 414026 527576 120390 414742 683151 287118 867485 930866 123001 910493 397111 942068 963376 301289 248365 429950 268520 929274 430929 180316 818093 685786 951911 910821 212130 931529 718874 810964 855362 899825 866329 817628 40289 142491 98143 63…
Output: 942997811

Example 2:

Input: 532 436 234583 780219 853392 70271 792746 143442 17963 522438 279258 932073 812885 629560 101464 672031 84127 870893 459554 332109 419476 39717 338427 212441 502660 651305 778469 229604 54139 904264 662473 770850 723287 202630 808783 55841 188833 90244 192161 247229 366067 262633 379448 807361 439172 862762 217779 599138 762948 819908 195896 617233 381738 170474 943876 31408 333922 593448 710669 228687 221124 445208 183754 421166 484234 876787 625482 581349 743307 56653 184135 921604 312465 509681 738991 783106 667975 544604 305152 761047 712928 718089 988615 341405 987539 276910 623374 240757 938496 710103 909506 467909 446426 413030 555473 856589 91696 187978 931402 809636 148450 660095 787419 470967 341582 599392 562789 16783 949376 657719 44524 720505 898113 162020 547873 624665 244460…
Output: 234413191

Example 3:

Input: 2655 2444 505912 1258 398637 476517 706367 32531 444866 184504 638041 282520 844595 950305 475428 953087 59867 883249 951407 445113 707987 281314 157369 647756 168845 115641 343437 186977 532261 826133 329619 638933 350918 924243 703147 805313 283058 37607 531460 193053 703369 676517 889162 372824 63533 545024 757177 197765 732449 305503 249743 422376 862709 381415 965741 45250 373804 129767 873790 643274 45239 160066 932802 154389 658586 22831 892849 69943 187108 29589 790413 448882 80841 341448 476421 751307 34859 594256 994407 74362 128765 681400 490428 456639 574749 136024 289613 813970 181870 881645 972098 942192 254005 86705 726845 161769 57461 109821 91403 481211 120949 71612 621495 71733 28067 907947 408099 260276 40136 970162 35299 489435 568427 56982 175087 205259 992094 743742 3…
Output: 1242730916

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Eklavya and the Gilded stretches - MEDIUM Coding Problem | CodeTikki