CT36356

The Peak per Window Beneath Greystone

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the shale slopes of Greystone; Cobbler weighs the day's beacons manifests and starts the calculations. 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: 1710 571 -833898070 681598384 -900954498 -529480143 551630387 -457890618 -677297939 -249584288 760901975 -517283236 -921695345 544643356 587010594 -635837079 33255562 -577468904 -276712341 -513018100 -961720080 952570928 -795835278 39168970 156199885 -352220785 -538413534 -233384950 574606478 350572130 -258909384 -386138404 94894858 294285106 839742719 -100210510 -666247308 549887584 258281010 75539433 -678680835 724689131 127356516 257240191 861085236 274492099 650214563 459476565 -839053294 689955995 -591963624 -295918165 -59956146 232499304 -914655686 997180172 -814630696 -520465233 26660745 848216636 974552047 277118570 740293594 786518551 323264113 -325811015 -13181852 -320704888 70122409 -548240802 -1483713 -332679243 -64217512 361126878 653824222 662002627 569737667 -323874289 53849…
Output: 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 997180172 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 996889969 …

Example 2:

Input: 2680 686 256802608 -31278371 -567975264 220058530 -288048885 380729621 -917239039 14544225 -724066322 498903636 -111455996 504994600 -180746584 -209600146 -284804055 -830778774 -51318902 688673532 -665476061 -489520907 854478603 680098075 -937565206 313219573 293137468 -607721662 437452842 -348174041 -881775170 -326326566 -653238136 -618321302 908123132 -80874104 52154041 -918795979 214162457 86798765 184008070 -999668704 550945180 529913087 -477968045 -758209963 137734864 -334328918 287087320 361983107 -445236683 352321441 -759818073 467592477 -792740254 595174033 150284988 465466048 29956536 -110562171 -786080545 -751515088 -757984061 399405570 186303154 236971596 -286671701 -705173335 65892862 708635051 197718145 -820932328 -538522590 -451303274 -973853636 880454898 -618771456 936808835…
Output: 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 999552560 …

Example 3:

Input: 2239 1931 604694644 360651321 293107841 -657556278 396121378 855139986 657444013 250783448 689945119 351621076 -374949128 -834628925 -959365960 245380753 -112182755 151239285 -382944250 66606898 856021774 -671131793 -235116032 -835229614 -802362108 -508732553 -836375673 -506049248 133002650 -552067447 632181951 529431370 -845358920 -493012289 470159935 808618475 965786481 -924451492 -320080389 52766686 -674298171 813574041 -421125386 517882062 51574717 -438635439 -930291449 -103105024 514364279 31499143 947792572 -30736345 -623728284 640354192 286974689 767012003 -503762025 -773077591 741575613 496654903 329864059 974553005 -992807700 263665289 -407305077 -163741308 421526599 559683724 370217781 -481552867 -462046856 -975374872 -135527155 47524437 267212111 680106091 -94796210 -337549481 -…
Output: 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 999769993 …

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