CT53936

The Polished Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Zaid runs the salt store at the cliffside roost of Stormrest. Today the books show a list of signals, 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: 2487 1495 533853828 878267291 951380682 -59333047 564051028 58004631 442274285 -941905252 -494308302 -896523189 -151409214 -122854067 459843344 -129142858 -745093741 132455759 -457092744 512240225 588195694 -289628736 12759624 -978452780 980075241 550327944 -299727346 526729008 -772665204 -112622265 -656546818 138251067 897797557 -649247038 -899081641 -712906307 547098799 934602166 518549848 397610124 225873503 -170389820 -441048759 786322688 -451782171 -705094513 -382904435 -201006442 -347907854 -731278552 -29945321 -408187885 -781355216 -225427724 -605203903 -241481876 2001531 748338825 -996083641 263389597 -695174042 216987073 -490817956 330247477 402565130 -708527918 461201827 305672882 -775796880 -283115672 -11841778 908098654 -518487609 -710199102 -544151821 -924657535 913823253 2875…
Output: 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 997437359 …

Example 2:

Input: 3568 3401 -207808111 972940224 755490319 -658116475 -217470157 679134836 -938845289 -195490383 482964344 -269568885 715174117 -632054364 -579529665 -595565112 -601966914 -932527634 982682589 -491447672 837239033 -15544303 774710878 -660911596 -317068329 -541221639 -969591680 -824602292 -721942117 428658184 -784094228 -742877941 -267388266 -403182571 58429305 239388138 277502654 525764462 -139914851 -402809826 326381490 848334221 498762794 195270151 -377347848 -737591560 -34293646 -878318711 -754219233 676123901 648934461 -930482501 -69176367 -378362495 -337951999 -171819789 724931737 929487353 932303411 439726318 -263278275 -364209621 -110733699 -848462011 -245867483 338860511 -308693262 9480754 718958008 69246009 252368876 822118162 -239013953 -614914238 -504832682 77165473 -825172992 283…
Output: 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 996868015 …

Example 3:

Input: 3251 2998 5936915 5978379 -455151927 808896756 864487685 486694188 -276513453 -272347223 -543235315 -223816811 -271918307 455804593 555705783 915586440 -895502835 843609708 -789744781 -562415032 12520922 500301366 645839743 -410715841 570390812 886001139 177212246 110229121 696770125 231546528 226664145 833384493 -783467437 782843065 -786803679 -199377975 142741207 837741628 -628169902 -821086870 -363071006 784346380 -415027315 472255706 624004379 -202531271 759436474 493457980 761512313 -146108688 -991063611 321584858 289630647 645684310 -410557611 418056422 -942356693 634027763 -820965852 -16205779 -207303728 -930055548 635054868 -498100925 -450144613 -403083894 -713066302 60390555 232771735 -871356896 937097571 -201385624 34083170 641149492 -64362895 -50373473 738737798 407989550 291670…
Output: 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 999847222 …

Constraints:

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

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