CT55170

Caramel registers Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the spice bazaar of Saffronia opens only for a perfect tally of registers. Sable 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: 1338 518 75031079 -865852830 121719401 -615994809 -948019846 114780 -813584352 -171320170 496260653 995715344 466632209 -841452589 212567850 409082108 -917032990 -707534729 235586343 647975230 291510449 91677849 161719226 -953616584 824874151 237886103 -964312815 467479016 33867312 -113854998 631797501 973160980 895426926 -517291295 61165102 433222898 753643117 277145176 -925608019 -843418073 -154875079 125386468 957580264 -66811699 -701263368 138835875 983807424 -112195412 -407026657 800488702 296557347 -804929043 509862614 825722597 515060973 547020835 -474199242 154025689 125343321 -372568711 -598000858 495067161 -264640511 -660652544 134829823 816749953 456631441 691960126 992831696 834304938 802900908 -571410663 141777711 863258600 -792389793 -693421593 -27292601 -390285824 698793731 …
Output: 995715344 995715344 995715344 995715344 995715344 995715344 995715344 995715344 995715344 995715344 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 992831696 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 996272610 …

Example 2:

Input: 3633 2658 462810562 989355303 -496154314 821741996 -359769558 -437460979 -546660056 747349319 638553812 -264832720 -623491605 770751217 -580689935 978226657 -60500364 875721097 -939243241 325705290 10411000 759772931 -301687694 -165114782 933508089 -313032583 502478612 -133980984 553780285 500247220 -87847556 -27382737 -398491101 -424634512 134928353 41900975 692416568 95031542 676917077 515986968 -368799328 -198913736 660933638 920906995 918854179 400162979 -554083229 426905810 437910197 378101727 -390263708 -866619117 -54544060 -903253422 273055464 379939387 25931240 49457565 96612253 -998739577 -861461981 123598019 423602984 229045902 129819981 715202205 467009096 303381279 754422910 879969464 -344372137 579132870 -243162103 358519581 239772753 -186726597 -296889498 -156950958 -83171980…
Output: 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 999127271 …

Example 3:

Input: 1907 162 805473292 35664158 194821263 -206627647 968408488 -137617336 -784813280 -636649667 811117201 484599708 313991396 188750001 552403009 873100137 412923744 -374465373 -492712208 341584655 122028936 -114169195 -136204995 -848342759 80936304 -251762986 -423506457 -390039709 -724189063 287025568 -91827521 180764150 -187120336 172260790 357021308 -718304759 57680793 -798263861 -814957197 -333919538 -326206871 478141027 212365478 24802737 732392939 -323799215 127318857 -691325747 -711667853 -207553298 280720335 -28065275 470847732 3166883 -124943842 -198410660 708822924 -165462232 -558199913 977819828 369974680 -139971204 854850590 -776106469 -883883186 516279514 309743185 212804847 -916231521 -426828945 792077082 -150139171 702365993 912847656 -122758973 -876838121 922147630 286598841 -6…
Output: 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977819828 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 977469880 …

Constraints:

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

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