CT60828

The Silent Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the galleon yard of Masthead. Baron spreads the ledgers records across the table and picks up a sharp pencil. 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: 2078 1643 134941935 -424031146 -878176543 -84380436 653907599 113352010 -499267240 919263230 484547141 819767957 -631231721 -174982409 278761624 393494049 185267124 -193693735 1607043 153894174 472248372 -973387974 -969298314 286145224 235626859 -357035794 809399609 245509954 -912853793 504121255 889613742 497060858 807461258 -81264223 486618134 -498996124 -649674250 -175757307 613526858 -683437241 800747455 -485417858 -419475061 -587033339 -33549780 -550103102 221367822 437388608 648989640 -565826207 -13976302 486813263 -35233938 624541306 -80979570 802777291 511319728 648556110 -728192346 372328015 -613764507 -22605450 451674905 450672534 -901767430 407598926 -939132514 -101553783 -776228336 -54653519 741391469 232025384 -999175112 616165480 564566358 596487894 -686826599 -252962613 -212…
Output: 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 999068468 …

Example 2:

Input: 1152 574 609264488 -410960920 -435145343 67501547 115041937 -869650378 -385687709 -557635349 -583447741 -232281670 -593575840 281712828 -510850883 605306593 -773029784 928768753 221241262 726867437 -910295366 -114225564 458159027 692732705 -156885874 413639176 930724900 466409734 -654887247 -853518848 203833899 704636006 -499400682 941084118 -227218730 -984492183 305590572 307945816 -699484858 -687567448 894915152 -32712168 251774708 185499913 135423155 697128303 -867587301 700684687 877786763 845656495 131511286 650299661 244545954 -22505399 -715446025 -920768475 -89252599 75553821 66285128 -636809511 46777707 -920223609 -169411278 -85884990 -544871842 -966175334 -296340010 102932937 500848248 485285151 672037953 587494939 653624546 -709790912 85828867 -622598772 -151909916 827622266 -302…
Output: 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 992793033 …

Example 3:

Input: 803 335 760165212 413025889 -658761472 -573119493 391690030 842320029 466336373 -961006344 -337042219 -484072350 515686877 321522494 965100216 -410560453 -615817207 -964425805 -473190910 866782845 -919093556 125982938 52484241 480736800 953329257 -405108416 -919244353 203034453 -532287359 575100344 -486214908 845053235 -844259351 954908214 -113662103 162222125 202486396 -244063872 -574615875 -617955631 889371727 -768550993 875189951 188257108 -96908476 734497148 -340379488 727199588 -307239380 249289026 -559576137 -942900286 994874664 648788800 677880720 -764250210 188833177 818964930 197994593 337667798 275580946 -855189292 979188307 282144488 -70443520 347152607 -327311590 255549486 353594212 346503115 -493201154 214827557 675722189 -800704156 366773447 -187443898 150738396 -485596560 -1…
Output: 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 994874664 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 989163032 …

Constraints:

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

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