CT57750

Ulmar and the Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the opal reefs of Shimmerdeep; Ulmar weighs the day's registers manifests and starts the calculations. 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: 1752 600 -542418084 591202799 911534174 563863227 902964104 -200999214 -12216340 977951073 -989486843 980530800 -13261048 -542429893 -238411935 787451128 778062552 -877684809 -423720619 755394782 -744084137 -901603076 560657627 -58475839 -944301640 256675809 -775116353 760879871 -761307337 -128749774 -346565931 -509891806 -35368040 417788238 -602577184 128350252 739042907 871758967 -974869444 -909974911 -603791048 -840918756 168766419 991809934 -708048402 720595801 198193815 598039912 -606209833 844920281 816505246 -802060293 299345474 -633438970 367793243 416721906 245378171 -764892788 62247105 -154341980 917654029 -266589326 484690459 -588318932 2931501 360115036 -855646768 -691884190 -838040812 786420583 -65191593 -667464182 33414932 409792372 -22184589 -421360437 65106547 603556424 797…
Output: 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 999352267 …

Example 2:

Input: 1670 524 537895629 -166662185 578999726 27501491 -358425211 -227659205 819421613 899111687 880688406 710390511 -27061877 -900815439 -39787056 -416288925 993733917 792522786 -84558306 311127546 730419749 -824252835 -671779945 764246443 203186580 -773851276 565140854 991768259 -576872404 878158490 -385096990 -966711230 -196413997 900757598 995563011 -224782028 483744914 -176453538 888277365 -872288992 -680268036 -186830095 9422288 -407463757 -276253955 537602817 -41280769 -396329984 268675267 670472525 914232694 345476760 -700240046 -196055765 -671544933 29913898 -455420737 596798506 -305602820 707420866 -343031600 304085335 -278604842 -243355772 957775487 376555855 397900628 208965298 -973047779 695558931 434686654 734156372 -768959739 -806027666 9305827 -424301815 161264450 -917306404 7373…
Output: 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 996544873 …

Example 3:

Input: 2925 1109 -486573484 595852746 -704454634 864360385 -379398980 -722683390 -887224873 -823213624 -567142906 -957945604 625816079 -916181530 -672765962 -349794088 804727516 833795879 458364370 560809034 -727890396 575230568 960339067 -361628936 207279180 -316574577 237361335 237190015 -636402800 755803143 -383435727 -524997378 -69087381 -743699443 509688517 -679420399 -93644352 861834548 795432927 -411023890 949069740 -427551096 -831834848 -667703199 -887885419 764706547 914371630 -895640041 992721483 -113119133 -460766998 -185243641 587802534 -145665292 550923130 759963406 -670233776 -552457729 665668643 708496726 -522582880 658018583 700129469 887648098 -267019140 -741338890 421268600 -521895893 -719843309 843938161 185055641 977902605 -205932817 -778215013 -962196531 -429478331 169346273 …
Output: 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 999066227 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Ulmar and the Peak per Window - MEDIUM Coding Problem | CodeTikki