CT63938

The Peak per Window Beneath Willowford

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the river town of Willowford opens only for a perfect tally of ledgers. Minstrel means to find out. Task: For every contiguous window of length k, print the maximum. Input format: First line: n and k. Second line: n integers. Output format: Print n-k+1 maxima space-separated. Constraints: 1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 35 22 958621048 87347904 -712531883 445595676 -250295148 -419346141 -879658869 59173892 209890215 -273894861 153725904 -910607407 -717841297 928457518 667261666 -470250502 316708585 179117287 128062649 929662340 -472849839 -324245084 -766345067 -902470463 654859523 597942625 655321177 515573387 -559348999 901364076 -578126967 -998157673 740321278 -799431033 -565718019
Output: 958621048 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340 929662340

Example 2:

Input: 1273 1198 -774170895 277982624 -248567117 -108288126 -358845684 -61181627 871104418 998505555 297853599 645341094 -928551730 368029264 662303813 571172714 -527496090 149674343 833527103 560381582 -348821098 -309777462 88731860 -419926374 998754157 945798029 -495261943 621685400 -766526349 996805825 -86840176 628268348 -446971094 323953033 435824670 -158685167 -188166186 -656299531 672700622 -394645260 325960294 541621069 357495755 -572168515 -339219870 165359366 381048996 822395895 725912962 -322917190 -237644436 371201208 -39292022 821080215 -729024612 143655690 -528116261 649972408 107572137 -742945777 -630495116 720497314 461874817 14585506 -798994488 989083942 33755211 -589840905 -49044018 -228658928 -461680051 595045839 -910395152 117451762 -478560105 -15936124 -337884609 -712342560 8…
Output: 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384 999640384

Example 3:

Input: 2887 1086 -255105630 897509354 440728940 -162551122 331247179 837187861 -238297550 201546405 -799069547 -771660610 -985282632 -778406148 -791616166 323143431 -719085976 996401455 234651199 -796177416 661134127 380425102 421865294 409989292 -559019057 299283189 -491641217 -644050732 842900056 654623986 -531207380 -534013806 -245715040 -236915213 -651102703 65476710 985894155 208271911 206436899 -825747539 -855556352 237701294 -604780840 -699369414 -977110890 -862479380 -461275964 311154835 -609308565 553126783 56390790 578575504 4385946 980249188 316466938 -607985778 622112456 435767288 -391279238 988964171 -695241809 673697554 -37497369 -837165708 -534366053 680706854 584297554 -246345816 -391934901 803282515 -363559707 -321629778 -506910408 -645533857 784381474 857467788 530150895 7804125…
Output: 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 999449018 …

Constraints:

1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Loading...
Test Cases:No test cases
No test cases available.
The Peak per Window Beneath Willowford - MEDIUM Coding Problem | CodeTikki