CT60286

Sunlit marks Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Zephyr inherited the mint at the shale slopes of Greystone along with its curious bookkeeping system for marks. 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: 517 176 -844159336 -258227464 -290994831 281896896 -257395914 -802805533 -109502005 298605094 212584965 47239398 -708744360 222973515 51617173 536641374 -602269412 422720878 -820133594 635740844 157346228 -504555050 -326201196 -200099950 -388593588 903554548 -496347090 -591420808 -326386898 -95023835 -682606472 -147869921 920317787 -805787237 -23844430 -728126827 965423262 -487175646 -966601613 257741786 -491377390 -368477366 476530048 304416674 386528527 -294137709 -391561105 -838813410 -123902730 -825555978 -25728668 595602612 -631734996 -819374423 251951754 954240661 -630298028 -810891478 611673847 22549116 -836166340 688264636 626373219 878285202 842193802 613168829 496516158 -636443790 71199539 -155735142 -906641915 148076892 -674489485 280207033 710909664 208823492 -590052505 2769249…
Output: 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 975812933 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 985401944 …

Example 2:

Input: 2562 325 675698014 -33921611 -795684635 68457280 -153856530 579635034 788602998 -93532069 37232677 -919586464 -210454549 -981847350 412264164 -799043187 -216803376 398860539 -925946289 -941302096 790690964 538422359 -741746236 -412286851 216260432 679269182 -719885010 -26148291 236597286 -936762642 -8715443 507033852 427151439 238887709 -463373097 354544481 -389723508 686328310 191916086 -906598593 -293099783 -775843728 -456910098 -681992893 -127404949 221486527 -69902850 -763933771 298394791 246487688 -724011281 401420076 607477416 -986659966 -288359081 -607765446 -421458967 -607471806 957875837 -875414023 -720097266 783479854 654994457 901833291 192326558 -326977632 807553903 54134271 -317262872 -457741480 497019381 719425016 -575643059 -402339365 -836876027 -239069113 -818339385 -389376…
Output: 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 997448112 …

Example 3:

Input: 1348 820 -164125681 998101356 -640001327 -498207317 -763497110 998767709 522266040 -975227660 68707351 85778218 481328689 -268737030 -998088653 566716784 -473320704 448052021 -305589514 615130570 858892464 777269589 442686081 -827492438 -892380857 -688571798 686664022 -265437253 -803354126 -710988645 185920762 -743185651 -679738720 -248950536 -69353784 -130852096 -830747954 393058892 -505258276 299899348 -875242269 566191190 425972215 -238102024 -428366378 631445092 21861074 -157554424 -615067345 -265490380 246791957 936278706 795903132 417266689 747575345 484387359 670036575 760157650 -887764160 -504356697 228711602 146416418 -128229489 -8760093 -198388599 -722643978 788222531 -151556206 -76604934 -952809815 706362167 500734422 324608116 -989601623 -456234773 941543617 -391634821 -6645987…
Output: 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 999511865 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sunlit marks Peak per Window - MEDIUM Coding Problem | CodeTikki