CT59323

The Peak per Window of the Gilded marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The paymaster Chaplain has been asked to prepare the expedition manifest. On the desk lies a long table of marks readings. 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: 3933 3272 -704110398 171394814 -353443009 65493954 -30385570 625610465 -459863418 -578072687 807105147 -446121937 -109918585 -973634863 -217437679 811412851 1184320 757884805 339259972 659647809 299098151 417833889 -891180648 -169584993 -74553814 -322643296 826649136 -947319239 -646742666 -777641805 -514808092 -158789981 62787918 11843448 -72552161 -224231620 643840288 -648466805 521807606 -588773419 973181302 390213028 264048675 -526280771 619369324 -644171149 836783136 -554438751 -71688980 -704911830 -87470818 -241369337 -360962816 25399947 331336572 364755011 832241007 -316452478 -79162126 919476114 91818043 606391062 -690694046 -687411592 455410530 349009216 -788344470 666007925 -303348927 247629493 841198832 -980253871 -289843816 -431701375 -798385480 -545474330 992771920 -410761009 7…
Output: 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 999513190 …

Example 2:

Input: 1939 1856 -985238619 654135456 -85418907 855665456 335648351 200723394 -345970642 783604109 381664342 501752170 -404387754 -790809522 340678640 476220092 568510333 150279667 -263133355 -544177966 713889873 606562657 -37996172 -475745452 -996702271 405080840 -859614494 -34813641 -179421055 -936748634 980814207 -530560950 -699307984 -489397558 924626872 -757965788 918807534 250142203 162889162 -553755554 339167004 -502784464 75179483 956544658 -168387223 -355172011 -99828179 791812394 -765890757 -688186323 155686122 70916831 314945311 -121452311 -433031669 66359271 169247802 78264217 -882879459 310267198 848097194 -836993848 518517435 -39706021 -318345037 -105357387 -502284582 -79780279 102133547 519769987 -728239467 -724768287 490906225 -652414917 -869012824 -779839247 -555568722 -626981910…
Output: 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 999803371 …

Example 3:

Input: 3675 3493 212074908 -176386007 953989900 747052266 -769945382 -584142192 813933625 881279629 -231254162 160337601 6018100 -606926553 -168577741 565553414 -812159246 -505042232 -582993448 -388532792 475512431 448993184 -130845988 74217714 -977950535 361034229 66841267 959252216 -51919547 -290280927 302908349 -58119953 -596350515 714806760 -516392994 -704593254 -794632477 -676719560 407382817 -77958411 -30762482 261539315 -140250397 97448826 521605669 765294833 189582019 -528042931 46764027 858913358 497689622 126584065 795112427 -954900220 -406186911 -128122399 495407299 -392576943 -879782623 -110443469 -600795101 29160552 -189116655 -842877031 -451585922 -884210720 -122123135 270728897 435521089 -382113085 766685446 210626776 802063525 600791967 -475362766 -247861143 -182847803 -827084487 …
Output: 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 998521037 …

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 of the Gilded marks - MEDIUM Coding Problem | CodeTikki