CT65239

The Peak per Window at Obsidian Shore

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Omkar inherited the shed at the basalt cliffs of Obsidian Shore along with its curious bookkeeping system for registers. Time to make sense of it. 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: 2706 94 301277380 351945323 485265352 685271090 -934865607 -795300841 -852944961 -621809308 530338632 536570896 846613036 476077030 -430685534 877385196 -554929062 201693241 923090950 -228023804 535276743 -346631339 -160334786 71737597 788058049 -465708093 -690676490 375683307 -630700698 776554874 660727379 162894847 787958550 181666237 671970328 864944348 235945477 -138732590 -731432774 930452986 -901326823 922383244 856364348 994052903 447069554 48555170 150883779 196334905 115661781 73443875 -700440977 -202871096 -302073032 -641255658 182954971 -65501829 539788708 11339245 -57819869 769965179 447325124 -465755627 -132612838 638146468 864649121 639203850 464520157 462751925 -669719808 -343255255 -378534680 780678855 970551220 305630762 -8306937 51308873 -16057297 -976868793 -937379235 -9…
Output: 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 994052903 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 970551220 920174770 974157556 974157556 974157556 974157556 974157556 974157556 974157556 974157556 …

Example 2:

Input: 2090 614 -953691744 -734995307 -296595513 448363361 300720670 504659993 -258159442 -263209712 -896683165 261313065 -372780007 -400834621 126282578 84667664 -255651117 -905336989 -660857571 316001857 -933764704 -502926509 511866201 -161304008 -170899005 864445348 -943811871 -874959194 -605391336 76611271 -665808078 -127631032 802072188 -178224863 -71155677 -120983638 -852805760 -773156259 -825191093 681397059 61914436 -52416315 108114909 -520610697 -71545619 -905646341 -104178962 10358716 -849593759 -9697895 -496641696 -140298749 -738069811 865999940 -610322111 256928653 -882868049 -640350545 -859692103 -758708745 -305999324 264996781 661658845 -210415336 716287907 699675407 563109217 -149407374 773754020 -417376500 771024081 170319473 -678710336 -147481105 -575527662 969802400 256372865 -5…
Output: 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 987061259 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 994746201 …

Example 3:

Input: 2408 1433 -131264513 221087549 -293904939 -310729086 154779356 -601354169 -694223829 787067598 741996140 916966587 630861604 583126940 720256830 346992205 -168542565 -163415502 -420896055 -469016474 23726879 313755599 564043770 135139365 -408081162 -356877787 769477806 -191116788 -458358563 -788176660 819450329 886534819 -297221007 282170670 -269042218 809059437 974853084 747667683 836288071 579650452 918690585 615019015 -426616540 670988763 -846799933 662852233 -185345210 -307279205 783676301 703546465 -348523111 834344648 838512082 -100931584 787882935 362683213 877874730 -150036926 669799526 669023504 560800566 638432800 -351224592 -718835493 -680028273 -661314418 -137866544 634652424 715245336 213776267 -628076625 -324353985 636474600 -241604184 988304119 -851347934 201624108 -13658219…
Output: 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 998714349 …

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 at Obsidian Shore - MEDIUM Coding Problem | CodeTikki