CT34518

Xara's stretches Fixed Window Peak

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Xara inherited the customs house at the beacon hill of Lantern Tor along with its curious bookkeeping system for stretches. Time to make sense of it. 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 <= 1130; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 640 273 686920147 663524424 825388262 524658458 509678547 76287531 175488423 756836157 383080792 453405812 794370476 808685829 614646387 151230550 503440291 216731232 678679102 94770627 269542040 827841150 239178 967423790 960145650 693404015 266855460 198166396 29368213 833317851 416421949 978418422 417142823 597180462 115007927 952878355 771251592 808027457 704804259 573911772 240950857 743282405 678382800 306111466 135744282 999558343 675011926 491443274 551942279 2631787 388815656 83559055 403164420 404580184 259442654 436390824 717645672 327580226 640733184 454742367 910466994 859373187 562735190 622545998 1321077 36560960 801734826 15305198 323379837 333132534 732185626 413875902 445349173 381811349 773901259 273469032 20290719 741641749 71259939 608556659 619243066 144430883 5482973…
Output: 138441764114

Example 2:

Input: 767 110 799028664 287025641 395048889 531805135 502008602 966684494 454471760 749311568 243819600 729230705 295586876 253636129 333465227 563516250 93578668 625294424 244807070 586902478 585689685 164078117 225723518 887739555 897837065 392567139 366072392 275255003 579039609 806357960 123476166 329052775 898007825 988602953 934404041 422579742 916079337 617747800 924381262 99029498 652658244 990724157 464075989 828415814 415601724 338094903 416868213 121421534 382209166 232446103 225199458 584556428 460424447 162866538 496678380 526536825 238927119 942280594 176650368 310206116 76338732 368879820 983586404 548332179 230508507 220789465 116393477 964435054 315613577 913554069 230531596 88075963 127169208 2589864 435727326 167405344 50355945 682439981 272502480 340182473 90089906 64782228 6…
Output: 59890367926

Example 3:

Input: 57 21 939101856 287655762 809896255 977926355 182495730 512874273 298931501 778585160 910761668 570526834 383029227 479624974 471994774 703454442 847343176 671129012 88145364 551830996 387131744 518381287 783618900 238448949 156462841 903384221 927513927 301106091 462004244 486753574 405036115 599079643 128157870 203088189 23107886 176619873 714645391 773864376 177236907 117173469 451011657 809369968 934582005 596512179 788338530 300221973 678883849 687363197 874102331 30566129 750067197 829356793 569631199 666001402 661459919 284333275 495384862 959966298 413136298
Output: 12435427515

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Xara's stretches Fixed Window Peak - MEDIUM Coding Problem | CodeTikki