CT59358

Viktor and the Wistful signals

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Viktor found an old ledger of signals in the exchange attic at the ivy courts of Vineward. The margin notes pose a precise question. 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: 3288 450 740681935 -742052725 513367806 182144657 -579231763 -101324985 891825520 -475139531 -841936502 407611284 -318666030 945043294 660883621 -277023484 623343260 245360699 -488137570 -111692303 -287023180 -140868380 -63139804 633042206 -408499502 -914665131 593611765 464423667 61802721 633680947 -960873281 560463804 -732564919 141647395 -425770271 -919969342 -765949825 210980952 747870001 624494331 323820751 986044917 634619574 323079355 822482477 630639719 -823665671 969548212 158134875 620931392 262103498 788944629 -528505363 454777606 105959848 506431095 -945724274 -263847754 -783301481 -387194581 -78702543 -754178860 -61590246 -884437763 58076469 -78507136 986057594 529620228 -14638506 -715874847 -699084301 -555284719 -989436096 449442796 202988401 -919861831 272420285 -948393250 8…
Output: 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 999981482 …

Example 2:

Input: 2111 473 -316980163 190394576 859964084 160990745 -526308762 -680251479 677983181 -484595492 -468648610 -606491987 981693640 -903393301 -455553686 -167930319 -895266084 -340467119 105064418 -315707474 11898648 917508131 515547464 262065409 921787828 477484583 -800204730 24673325 -173516672 140978723 932921880 588802611 393184967 -241714236 867762473 783339923 -958303749 -547319156 605546787 747720546 411256931 425393157 -191496493 779311507 258124272 693362149 549023709 -848481646 262988710 -117660561 156485168 -423557555 259190587 -949922539 -560000317 -285845137 -183957341 990537053 288483725 -619439402 -765538503 272226546 -49154798 -905787230 638689927 -254844683 718131071 -399844004 478056929 -382403362 208054700 -135354309 73903236 -805222728 312288581 -559438008 -964053602 -78240016…
Output: 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 996950229 …

Example 3:

Input: 2450 2317 250376396 -830219357 -334099206 -185722037 822592893 -406440404 -684117342 971676940 -112184696 -173590889 951432450 -445571170 175116428 469242692 -383093209 975914912 195517062 -358378522 -688265622 30038670 -364073797 989846324 -935095186 681802284 -962826720 -874326059 -371694439 -804535114 -835326178 -914369619 -423280000 -990867933 789807045 -803423012 798421329 842717787 -484975469 -774542814 -49272736 359013221 829330567 -584142897 266354479 -969404593 559770406 849713858 521733651 200252895 555477360 420726143 607755106 136589964 -782296029 -91257068 290286774 736041388 -490760756 883217189 -725395686 -811987611 1362543 933949555 -777977352 171838910 198373871 933547526 394467176 315395403 -520816009 -394867093 281074034 -761191805 -159856783 317763817 473896461 52830298…
Output: 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 999703989 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Viktor and the Wistful signals - MEDIUM Coding Problem | CodeTikki