CT38358

The Peak per Window Beneath Tangledeep

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the kelp forests of Tangledeep as Lothar unrolls the day's manifest of ledgers. The tally will decide the next shipment. 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: 2060 1891 -119867813 -315198048 54915992 411635012 -535806283 718470042 878717574 664103675 164877565 -709488123 274277257 -8429657 429280566 500204093 -675020117 -900943557 598827273 30823277 58211077 -401987848 332928801 -449026013 -201607462 995192881 -467608323 6547666 -764576855 -678570755 410666835 -550250891 -12343085 -26643082 -503476256 -147663407 61250403 659181791 -55254704 -905865923 -747920868 -100133541 442398744 -581699578 -433912824 -257121693 -279243750 -291792628 851707007 -485344880 -46921030 -966139351 -212759070 -951212376 -269852751 443034020 440546411 -910590676 -920133625 678386665 -355705891 825173211 -789775271 59779294 424355228 -918244895 -320387998 833679434 261730881 177811741 49229946 -467205693 514948473 543648127 562190663 511491329 -586461730 946580651 -48…
Output: 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 996775147 …

Example 2:

Input: 3478 3418 -991879122 973580968 -694172021 752739360 947785390 -832413951 258028433 805332238 597891163 -354869733 -958512609 52765182 401341232 838494251 745472316 -8115844 846454096 480517315 499931273 -55213124 -436167612 -33251194 -723707041 185260441 -947252491 683411716 989599094 125600100 368238177 758804581 -882814228 -303247502 764336659 -898072896 -635049247 480294992 -889529454 15659861 -727315239 947558893 100723718 512268097 461516787 -967747621 -536332921 463887742 413300404 943716369 -182815772 807134275 718109284 -859727432 430279474 236074058 480552595 -423572015 133538589 -953103524 132629679 642730674 191711912 34231462 29591770 742106687 -820663251 413441205 -355036055 -540684734 -248025202 178307622 -912318811 -617195915 876463807 -233301825 129661556 -29055216 58781871…
Output: 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201 999242201

Example 3:

Input: 1345 948 187975256 -456344903 -163945285 153158163 853631122 -191416044 563721077 263963634 -75377035 -85349160 437105346 -897296184 230422229 -384484782 -66797875 -821125289 929733990 -5621648 -868166465 79589435 -789266387 175047116 -730017836 208884274 -924638961 -496602200 119345291 444987266 115913706 -566288985 -374206613 470704312 703970814 -288171718 460164220 -474542510 -390141210 -921252211 401334535 -17744100 447901027 -510075138 387598464 -306120754 -647078199 -208045296 -213606897 784975048 192843038 -984636981 -206024710 -564227198 -688233746 499959237 549878152 42378488 -745578639 -769501775 -539514821 -190984518 -268203268 -505777629 491178284 -327724270 -520322742 -758178301 -417643085 -102112588 -479285141 -499748427 372565615 -434329042 -237538432 642334327 -275244512 97…
Output: 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 998902487 …

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