CT64088

The Peak per Window of Sleekwater

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the otter slides of Sleekwater, Jace records each marks in a worn leather ledger. The guild wants answers, not guesses. 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: 3746 2517 183061772 169417308 977402885 -844642016 704478028 91876233 67897884 -196797903 -352722968 280711366 -171733106 -570910797 483258050 -177090906 866463080 -596659006 -115480890 -463689872 439575960 943365399 274777773 532253496 -808664063 38750038 947730533 -400750040 -97840210 -481254758 344152961 73096521 -831838376 -670280840 -139030073 984778240 581445537 285406537 -473238976 -634183670 290878481 772627551 -274090526 861693421 -393415589 -490020065 -417364858 848056797 262427951 555627387 -660531391 -87331118 -566157856 -936801431 405225386 -813670242 -160093703 -959336088 -738817165 -256048057 -770294445 912626046 248853709 995219686 -373879145 956119619 181591248 -390624753 -709355877 588838741 42787881 -611837605 -768682262 452759682 309198371 580740823 327149863 -252061951…
Output: 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 999886999 …

Example 2:

Input: 1377 353 468900745 284301314 597489098 939193941 570953355 -489799650 -470657576 372482401 466495599 -397345368 -378889776 -81233115 -806418822 -97742178 -288089934 792630830 -10795488 384305364 -287260547 404269988 -675552466 584513652 269778503 972266813 -371572180 -474627866 219055695 210997530 -992050952 925482664 -486332197 456346380 322383003 -372855095 903333176 -738433770 714054579 768383631 -440521115 -434081500 638128277 767106104 -126190247 15354992 372148736 728380879 -149244615 -571513462 -742031034 -138427380 204625444 -221830449 -10151323 452796139 822185554 -501691395 -939641122 659560997 -126602409 -41065084 -311128769 944537412 -335181627 -508934812 196065901 512716376 419194465 864805487 607430715 889852483 915215259 -332482169 -687463659 -878175545 897292291 763621284 -…
Output: 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 994622773 …

Example 3:

Input: 338 127 -970252581 -43995681 546056982 -543903335 -483138330 754725021 -741008638 -638497421 -188356042 -764745451 681062017 -150959915 -684784701 -518410855 406957738 500700942 -791441920 -764372054 -718179588 405691075 371162621 -522859301 -910296280 -685605243 617364911 674008015 -637350815 -494802331 -846981925 156556231 -852953798 866241430 554434710 972132221 154327660 -170787594 -321365024 -336057175 116026711 -49155075 778265536 891705872 341876030 -202919463 -610185517 -782712886 429944262 707898036 -596696231 235287974 -158829224 -305752613 140574471 -322711543 172788443 478152617 -305641539 48032868 -910133920 410410791 -252478832 777407866 -271079630 -643473050 370913287 -909478390 -442257827 -931760665 -347507818 -410150354 94521668 -64688867 -258039779 -838680029 -372899095 -…
Output: 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 972132221 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 933415006 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 937545786 957646660 957646660 957646660 957646660 957646660 957646660 …

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