CT60429

The Peak per Window at Cinderline

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the railway depot of Cinderline opens only for a perfect tally of registers. Omkar means to find out. 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: 916 327 800721732 -205822506 -885308624 709990066 17636754 -334727749 21603354 -850829397 -666554231 -154380600 -887744640 -636887536 -621526310 656258282 -30207186 -807447093 -9838177 864509515 398834991 -704158316 -292507822 -384436973 -712666184 -348659014 -664118859 710532392 -769326652 -945434377 -107621546 300528101 -912409376 115730992 779371552 701076230 -539880172 428200724 49336667 458487280 -217012343 -890740885 -933954062 -556449265 -134904077 602950189 419821303 989457770 404414690 -615704713 487666052 950951794 545170245 -362036267 -385680179 823391682 572380732 -733350968 475001216 833233773 743784335 335749752 -765452560 -597405974 323067255 -795971748 -408424184 188992571 -397101061 -870709982 651622487 156649234 189816243 21001893 827553860 850470634 862555366 705246555 5…
Output: 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 996105535 …

Example 2:

Input: 3729 233 -395570434 -405720053 155659188 -626447498 935801585 156783839 679057156 -59537976 287242040 531286281 -807161309 753646795 -654308208 772125235 -659172140 389833787 -456128670 398359850 -774192021 -703334998 -539884646 -469342736 478245725 16461042 32722199 147507850 -542262270 -623078195 977710295 241220348 -299349753 387602838 242479275 -647240043 -961378532 -298169295 514492854 -607186923 -958055610 -833172538 926403100 549285318 925908006 -393187595 166248618 -911864724 -50842172 -611879132 44003651 -503404847 -808070751 952907207 504508918 -527191253 652733678 181772965 -853320923 306662462 345377328 98159646 -640343931 941537441 -563628728 -491724821 91764445 318359345 745278485 -421484344 791269461 367243082 -243856579 912938936 388952154 -97522927 577641561 -208873402 338…
Output: 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 977710295 976425570 976425570 976425570 976425570 976425570 976425570 976425570 976425570 976425570 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 994652210 …

Example 3:

Input: 2665 1898 -701672809 -720133543 -471966744 46662673 -575682261 -462202965 -622377701 368169768 364167874 -927782736 977232128 178826121 795556318 -788361445 569500664 515398854 -689055235 670296675 38088719 90588103 596923889 923230947 -204867653 -825124671 125169912 -806815612 792774760 489052807 403803806 710810204 480353449 -752193947 281144694 745880337 -446079944 -987500055 -679587907 -542791601 501097481 478402298 -225187072 21180827 -764970822 -175823144 694786138 -373969915 889196846 227889354 -247671628 -193309003 370116728 576671866 63782846 -610333007 -840011390 728754601 757175918 193900355 -164246934 -260770059 683104094 -5004711 -509404284 -787925125 935729400 -817380134 -821397029 -806091036 689831248 998795929 794244421 -549173529 -820101624 591781192 -577909575 -522152494 …
Output: 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998795929 998417505 998417505 998417505 998417505 998417505 998417505 998417505 998417505 998417505 998417505 …

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 at Cinderline - MEDIUM Coding Problem | CodeTikki