CT49784

Isha's Fixed Window Peak Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Isha the auditor watches over the gristmill of Rye Hollow's stores of scrolls. A careful computation stands between order and chaos. 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 <= 1888; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1853 43 165503809 985856308 178538655 871667858 808005613 760091371 99151978 419252249 165245272 521314439 676981611 542535729 152197905 778978111 932304790 799353692 141405533 69618099 212980042 474990516 321312933 687104028 915538814 282587045 203442613 726622811 255251192 753803064 644245149 326558017 573623432 28615619 178249719 342136363 263478652 545281253 317309601 991104524 578894840 117988310 748765774 34032790 19898174 359928425 143323012 525695219 868924241 658261216 153020030 4768460 473635367 184331938 887006630 696424464 921757580 180048297 4491989 318157237 910948384 976963974 207503588 409714064 823559966 148532534 3244734 990244725 805793103 129016402 440421229 222760238 776010273 84943466 15721234 725184321 395674399 935073338 833979531 408029528 509419572 864055005 94152…
Output: 27543910365

Example 2:

Input: 177 6 740012702 109308218 331293476 435913897 681848087 396484010 778051271 852624610 302510967 44994472 67329778 504698005 456228760 683654395 170251923 777467558 772924893 352792095 222941887 881215443 540916178 472089662 959391393 685270982 681983597 821870324 655796088 222940118 56388789 700033682 19096090 269644301 262673725 47990801 519143062 266951332 687027013 876090263 228372568 148952740 189941268 586356013 622509988 397969917 780639205 707853235 106336377 558589371 744222430 755588476 191461596 805479707 190745014 962340131 675506762 494313424 13745282 717946153 248646890 292284552 101953440 980701171 565006795 8496831 819632473 303194118 784609112 143825425 747002101 132121017 89067818 530291452 218506700 823607069 551542634 848613069 24738398 883149923 472629086 395449556 1229…
Output: 4836728899

Example 3:

Input: 1815 861 957118352 848386611 23140261 532806032 -220849 783252625 948554091 933378608 137572321 202875601 611210062 581815537 729899206 332287998 177539286 97300894 287025493 329713586 748928528 944700604 597335509 687090548 228673244 721345631 938511273 198526409 254811854 227097604 646241007 282162086 57985341 14426132 158888594 249621338 836614477 540122533 696451115 978553360 827334829 438005782 499644158 341282664 653379806 53441026 81327864 791344498 889795286 465033300 158081174 53741394 177199803 613209352 637048761 867650596 228732376 947144085 336980679 394398294 648202066 940557918 213437104 956769201 840789699 22154507 535646379 784253076 191538027 293581263 172207249 671669897 939698430 17213526 553287533 285039063 431274422 912188778 253071517 892495205 16417246 329195367 419…
Output: 442308220803

Constraints:

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

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