CT49132

The Silverfin Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the herring shoals of Silverfin, someone must reorganize the archive shelves. This year the task falls to Freya, armed only with the signals register. 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: 2864 2206 -391966466 -306203934 -218891359 -451459017 498259165 831449177 -561796976 -51910408 176262587 -667205586 -920294228 -153232966 22098519 359059336 395870880 -778328957 -299226314 970505358 795433462 471962863 313789989 897552515 -399531799 648942267 -612931826 -309626058 -172367282 -788492524 -83618216 -51713948 -845079692 -33611842 -934800418 -237726460 434296878 483270165 -361021532 320498102 -149433011 541362574 -819632663 436013499 -621911535 -719437505 -537754308 300242746 -165387221 -892150178 -652846130 -518024450 -556604712 15238017 917835674 -566928025 195496232 -978032770 -918202301 -70212437 631577065 -919262871 -768194830 -275969367 -346074359 -888101034 536368957 902453823 -848610367 -82438115 377738656 -66998629 94580196 689640898 -951840419 -839883744 787084833 226…
Output: 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 999008955 …

Example 2:

Input: 2005 1876 -791257394 -685517296 -148988709 -494743549 675009143 -692569405 -584793623 162214151 -349462092 74153577 -153114261 -682065060 -429903878 497060017 -776842431 -78354781 -875141115 394564900 -609041999 -58709797 -737560711 866249591 -888374408 -220911099 858493498 -635362843 -590285150 733308381 -387802924 797454316 611524894 327236638 -974508278 -110243154 137543971 -178969981 615852246 777307151 930618512 -816326735 -57254236 831408401 305519366 -814499452 197197569 -625672343 164341234 745329929 369676249 75121519 609737350 -117045821 -663003793 767851076 -73410062 386384301 -796475913 -611817750 269937846 861360352 864169272 -360814243 337050638 -786279192 -102338930 200564503 563731729 -916121485 -121793645 990222964 -555903198 -7777204 877671103 544667042 -482081547 9112369…
Output: 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 999859772 …

Example 3:

Input: 2467 429 -649622840 -238478471 -327468082 225472797 979122319 734896080 472246611 30711322 -722790345 -598878115 -226234941 -200135932 666892396 -219216107 -781665383 111238603 -146288731 -31916349 -238726771 -487938000 -652462183 -435767441 885061368 -24892915 -42870849 -222214605 256039018 996018051 -319385994 -819470524 -381130082 -725772040 864050134 -82140475 -375044273 510624932 -417607227 -783121995 -59960418 -179075738 -549276966 -89533840 -916198540 23139017 -934968512 894809354 -98873175 -600596352 865002991 -432085841 -792329261 485828708 106658526 -361833354 798153221 185958842 282703333 891162686 -883437448 959417791 744291816 446984631 262915802 -792454758 -106199750 632418941 512500445 -984058560 -104258205 -59612582 852207431 -479551112 945536166 502910500 -389178398 702933…
Output: 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 996018051 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 991072286 …

Constraints:

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

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