CT61024

The Peak per Window of the Ashen registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the bamboo terraces of Verdantstep. Alaric spreads the registers records across the table and picks up a sharp pencil. 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: 907 137 -350400795 607773176 945218740 -567775866 -628815079 -340440017 168042783 -219012452 -164190831 -453937662 -239375048 940105003 -759846567 -102737351 -182762361 123130291 -758098337 745122811 332281070 2424438 485544943 -35574798 142797830 498885280 954009362 161663792 -964464293 248340740 -183026177 641296441 683501024 -431645938 -830691554 -257684343 -709372920 -839225026 -124315845 447177768 -878181521 -955654114 -755360489 -874031276 291568500 -772122242 58013541 -993005611 793499585 153828038 684203547 412920915 538052322 -995194289 -716519657 -817878928 855903508 -387595918 71368646 -72400902 -204471314 171212588 -526402520 457770784 674571098 990664592 741257817 -959424402 -369661195 112891083 804221529 386317022 237302462 -140038697 122746500 98583819 -503628173 504781242 1…
Output: 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 990664592 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 981475762 …

Example 2:

Input: 1141 725 -413318950 234555293 -968842332 750237138 -244900641 -270825764 -827666382 295821888 378479541 -809774446 294197438 10243786 119744965 897891704 -834060425 834283390 -507342959 -946469252 -798356884 -950567213 -435398852 -445714046 686912143 -629943798 608904987 878925867 586031950 594640695 824626557 63799736 711842750 -640694378 411645402 -316302436 135725597 -995403914 -897009075 273885767 -931302464 -21525948 916035226 -817453210 755588291 631853476 -295803356 -571925340 115847962 -19641370 -434402028 -121019914 655687309 -752570085 666209642 374257559 -182087918 -47007036 707773502 742040580 -237333435 820161799 -278291501 602199346 -845025155 -19230754 -946023893 -152663131 408262651 659146089 132865591 513097898 -6145384 778794140 -926042964 933708650 684616681 -172828706 -…
Output: 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 994555484 …

Example 3:

Input: 155 93 -625154572 141142484 -8885176 196821706 -585733819 651984307 -870169018 -661804749 -423845204 112374776 110352026 47332724 321557339 823067100 -179803951 161547811 286134319 -25634420 -150945316 154686462 502974512 -193159848 906136099 759818227 887784887 420689372 237359181 138217778 -592064026 -277738472 216110603 -190608895 21274344 52915318 -872713748 674771276 -575620565 565566366 451187992 905442770 -193508713 -263198988 460408108 -886887383 946227562 303811482 68572645 -77370082 450927858 -537302676 -202690703 -663705191 -880838898 85477347 85597955 101303546 514753802 -54174622 -631083648 -425012979 10011979 464764133 -843169337 749883551 -530012370 -813229033 -419466589 74279431 -216392706 -913383385 -605877611 631349194 983368786 392591002 117126580 118016633 -944913878 17…
Output: 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 983368786 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837 993685837

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 of the Ashen registers - MEDIUM Coding Problem | CodeTikki