CT44180

The Peak per Window Beneath Gearford

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lamplighter runs the bakery at the clockwork quarter of Gearford. Today the books show a list of beacons, and the numbers must be worked out before sundown. 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: 1593 1303 417444581 -669179279 -784535178 -995939367 744170252 736251550 30395511 270607791 231097835 43767157 -522848902 -742649281 138193191 -13464371 810777540 482567943 -265342094 -318610619 -81377280 -658912614 115689975 217647651 318326045 802122440 -630195426 -225334970 366831193 438843313 783596531 -412554349 -241088959 -238973923 493385591 204092368 985997591 -341760455 514685920 -626332864 742864688 501324767 326911562 -492554855 -33905103 238685087 -190092887 4713594 -696093184 336120329 -115056783 -794625307 -600945702 -926529802 -467748421 465328751 633493085 -832728648 939021395 -115221527 -907008110 916150310 139129328 -575599755 618333084 654063148 584270528 679170233 486484110 -350468006 -82924824 779902525 95771546 -604440697 551917580 -790157005 4310631 385625701 3800511…
Output: 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 998994798 …

Example 2:

Input: 580 116 -388241624 365795906 553466297 -665961984 325295240 985689930 853155547 891773127 -367599702 374929731 -726942072 4488218 795556985 -513018853 720544656 -979448173 880582730 346346113 -346465758 933979719 532488719 -448719205 -528099996 -319990359 854591964 975395974 -962091823 742735396 358963552 -268666856 891545090 498577579 738948643 544954420 -943786127 -223257529 -739386400 295821737 708727029 80799259 945633235 834245810 382400523 -301895045 -378826585 -259501317 959284875 -177399924 -468173839 187272311 176244008 122132788 974763220 -315898976 -138650442 282689688 -511648743 450237030 990059658 -837976362 -924081515 207874475 294138747 981241765 -626173994 -585268199 -425531857 677723486 133668499 246351343 276929162 31763888 -8158670 -49907790 369972679 -261568541 -3332461…
Output: 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 999674838 …

Example 3:

Input: 3991 2590 142583333 911657553 430612219 -940114024 -853792859 -921257653 675953993 -964198235 214155122 844081430 -740459781 509587368 -34408030 781419596 -304518775 -980953650 -907161969 -1673850 -311839814 864472963 777839534 403148289 441258027 -274872351 -512295179 172312824 840893546 -241433273 200914090 -585619955 402431257 621816866 -314331144 -543829471 973732899 8741406 763315554 259259329 322321905 363654112 -710628499 -1154383 485392801 653103043 -957602465 609881295 887824982 191372906 -413460139 188792886 638801417 140902466 729228700 -642978771 -406213068 -833408702 248153976 -578200755 -172418750 21421237 114313576 183601437 -974510640 -894333463 -325364255 59425771 837690930 -330229787 953385614 958554235 198369306 308683750 -952074361 607867490 888151087 714938784 88045211…
Output: 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 999888670 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.