CT64024

The Gusthaven Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Lothar inherited the dairy at the windmill fields of Gusthaven along with its curious bookkeeping system for registers. Time to make sense of it. 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: 3383 3381 414505291 -494458510 514089283 -819232031 -715896331 -612596197 972090801 -443729994 -697571367 553518324 -969822228 408696782 533735586 510004890 -788530586 362746648 194848218 -891412995 -264863929 -862321101 556443304 379658312 -657562576 -755052773 721317155 248401362 -28429738 94218332 -528882304 442272271 -3239060 641261293 348688021 600544416 47801697 989985725 -566256261 -882515762 -255839604 678271816 747416636 -407868325 818476697 -341369782 464244652 674824592 793933543 510659511 -895946392 709625980 -218390504 -959174884 292116848 -870990458 200311426 -291535881 -569847829 -832882164 -970657046 -755603671 311920922 186007239 -183965746 514826488 -37528507 -929059440 -360375225 -303373782 -462485545 642247310 -484122624 336852183 29760376 -18734842 840998976 751743014 …
Output: 999946542 999946542 999946542

Example 2:

Input: 3138 966 614780279 -48984954 -862185293 234942069 -977485305 17906448 -297640739 -952688746 -96611823 -744236420 -709544798 212779177 -122028653 -503688671 93817829 -25651750 350933440 -836152377 -101617805 -863759530 -331547667 872141833 -3688859 -747255654 274110641 -477230013 -14693013 -286554599 953652647 260411917 -132498818 579895967 920643050 -817777988 513325082 -275924494 -977988596 97900234 -93630913 -569214320 -122260971 242829756 -815944279 -550227474 -552198129 381166002 -306064951 723938311 -470735294 52313391 178591834 -756421578 461428979 -425967288 125220515 497359882 -234174572 -213233482 616485153 -147806673 -302915306 -904140649 -555014500 -315104536 472823767 888269017 -766557579 -419864634 -730324974 -106987516 950814529 -504659564 -153829856 941420836 922412514 -8433…
Output: 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 999619384 …

Example 3:

Input: 359 209 -741034471 722228142 -651334633 -320306511 -55005965 -482917093 975389179 192534260 -968657783 252140666 909244442 -792150554 -451268910 -783595233 -950795259 342570267 208880360 629162945 890217527 875876936 965509773 394748809 911913190 951069336 473037951 294134479 47431305 796274540 -170499330 745981465 997740560 706773670 -156895384 -625209438 -658010042 -98754145 -939588317 67070830 -760218361 -810283144 48711785 -843643556 -311547316 -382893320 -505126285 182694634 -560559503 493622509 -228622591 -119472851 -63549094 -496275060 974640290 681348426 -546754013 641368003 -325183751 -479191476 -117730708 -638741357 499127056 -681981195 212747195 934988820 497308524 -778782857 -86254073 243893826 -255026092 -258861350 -628746881 -12881382 20359324 -376407418 572468136 191897894 9…
Output: 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 997740560 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 995489892 …

Constraints:

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

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