CT61968

The Peak per Window at Blackglass

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Notary found an old ledger of marks in the apothecary attic at the obsidian flows of Blackglass. The margin notes pose a precise question. 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: 2041 1725 -168266861 -19168287 -372192082 570702312 178468803 826938882 -822332054 -545892067 992110249 -186744685 -732558538 -233234159 -315122773 -5404586 -908262636 12396268 872940470 -143036481 163792328 -366127754 643716811 213527417 951953431 -960985170 613941566 -136937198 998083268 601694914 383843325 -331781742 -589462963 -61071605 876473930 -619578604 742296890 -390868854 -559663426 975162963 -362251418 427563259 -586778476 -545162073 -710328533 255952539 442316042 -183904770 -418310647 -389446896 -18112167 87026419 425612239 347467691 -78861421 116241416 -663767040 -821072284 -435957303 -992196918 473135354 205909857 254090278 934330324 -236733488 411061585 158069139 407874253 515674799 670784848 -962812003 -563403194 -792004913 581383351 509958343 559547323 -299497940 -77884121…
Output: 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 999754861 …

Example 2:

Input: 990 263 536576480 -594768696 -132442571 497659235 -193432417 699915050 147709007 734098112 976518942 934273724 394355689 -996988717 641259633 -176361791 588986979 665127204 469578070 -250876549 -239132836 572069794 -774307843 -534781430 -214657795 134945286 25147735 272299423 -510829621 345648770 -419423571 990984628 -672364805 314849667 -671202198 -28651169 932630722 18346573 -356465106 -255070906 857271177 -378327053 -722816051 878641385 -726985883 -324737724 -889903235 285624019 582516807 -24527438 32160498 500192075 -26464751 -75209169 -476173404 395200379 582365454 443635264 -369657866 -468890347 45093858 56925687 242050636 -625586318 -975613126 268567966 278058943 219423752 -361079586 -284566958 769630790 982484292 -565574280 417104481 59797883 -790578199 612899768 111309676 32046872…
Output: 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 998301344 …

Example 3:

Input: 1837 448 -790495681 227249282 766854995 -633472533 385689095 -674487805 128730656 -8360888 -992430822 205884723 -725082245 -96942360 -479938970 -158148798 -584345290 149647324 696942561 -165466182 183079067 -35029791 804001351 -744657095 -200353094 263134031 614706288 -722073797 -606975247 -96094591 147691481 418824611 -110035946 -202587569 -398326761 -633044634 32354956 579323375 876614329 -284593805 888369946 -75209870 -227345774 641499310 -809714371 667509279 -922503562 -602630094 -687960033 -773001027 796109000 -529828661 215229329 674860554 -586809536 -798776355 3901587 32619106 66643693 -500494067 -708062799 -359344536 -359097535 -1706869 700739755 -325708252 -995874646 667088358 -344830405 -844247544 -705695076 -604156771 -806165145 609885034 167383584 -321886788 -288978935 -3537329…
Output: 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 988711830 993670618 993670618 993670618 993670618 993670618 993670618 993670618 …

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 Blackglass - MEDIUM Coding Problem | CodeTikki