CT40833

The Fixed Window Peak Beneath Rye Hollow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the gristmill of Rye Hollow, someone must inspect the delivered goods. This year the task falls to Rhys, armed only with the windows register. 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 <= 1913; 0 <= a[i] <= 1000000000.

Example 1:

Input: 369 18 177531990 3026054 457430573 728462909 401358147 400825835 679059098 135975056 285307812 874544389 679309513 700671433 984890618 208480800 201993742 237055189 585429305 744714079 597817655 664192487 448731813 989777859 791317026 468683250 416839689 163471314 969161038 79115055 807540492 617716475 518717477 255967961 865871191 834835563 503860221 221215884 3663962 113406061 360049141 410394259 518801302 592229179 722504291 872132801 539841450 792272124 537795134 332247599 860617443 853271190 784804047 943994551 601088992 564075559 581757370 688989915 719725106 427207749 362722872 90426659 892643301 285860278 646668927 367838467 431694224 115499835 316647904 557719875 182809351 681385702 798940967 35155985 816566952 92554423 530618654 636373415 85954395 948292240 519197146 392159317 50…
Output: 11933355802

Example 2:

Input: 1912 1642 31924631 34592961 993277562 84883020 475078347 311810405 489113805 411051517 17866133 704778790 913800904 293705326 10007366 758512149 455513125 840209994 851673015 708832840 284359779 38624633 117803251 383290602 500308102 421615905 719378500 532525087 139405830 551938500 910542310 372928896 158438929 565754718 303456297 942976082 981138345 912150186 262182598 884322429 277456029 726059877 79591274 381776899 824017806 785946909 722110443 82108894 695427944 980312808 929166328 540596400 610232906 892475870 545705741 844578865 652559092 653446479 776365559 925916468 242219071 364728845 55331978 298692576 778685846 838741971 756490950 182570437 575149631 874869672 937905986 824012761 834875365 410877749 739762893 518818680 930520360 187394731 912246156 291975363 973059345 559714459…
Output: 834753519903

Example 3:

Input: 1700 1396 469023724 836062 463929164 502775474 732457095 796165711 361852377 686316698 382552516 385261075 304883262 994089971 433502472 859752345 133368551 28289551 255408440 247040582 788127175 906638164 121751109 471625175 306879022 184159891 654439576 844842193 60416626 840532912 114316700 980863664 837717777 377893862 413421134 380499337 18049861 779107565 119358141 235554776 292747948 134683757 524446037 643343770 986170292 352887092 205859010 633612747 164763512 143683191 274991752 145001988 432073124 342873721 287517190 217868246 420650289 349394991 483879323 167793352 198457511 264029475 69284469 531469777 296699211 541208550 887444127 174533427 290722028 672097020 115018188 874390313 13021160 223786929 945768555 830595305 433343038 57654839 714307734 633479175 435320262 757701581…
Output: 702752953911

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Fixed Window Peak Beneath Rye Hollow - MEDIUM Coding Problem | CodeTikki