CT52090

The Gusthaven Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the windmill fields of Gusthaven, Milo the factor keeps careful count of the marks. outscore the rival chapter, every figure matters. 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: 3640 2287 -338352845 545354543 409738104 -196174233 -614090803 51750611 134794893 710142692 529131265 -361788100 -182257384 -662579160 -954720993 -872858575 550508547 -989986488 -956484020 -292678337 290295155 -86693631 346865181 -708900443 841286644 478311338 -820441857 464996123 -135465493 353798880 -106572549 -759675014 619250208 -522198684 -427004725 548199219 980307120 631529207 -131105991 -519529990 -846858148 51482247 -458915106 -958487180 -68295967 678511879 573996739 410474924 899211576 -86652672 -762292306 -387858411 364088124 734686335 819135678 663390598 -690165499 21617864 456470278 637988251 -839462687 -548129936 -625359371 916483168 -318812871 -929592675 338865120 990366150 244994595 -736522567 -407502175 327416544 323265015 -873727698 772966283 615622519 -254262509 -7124403…
Output: 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 999649322 …

Example 2:

Input: 2688 1651 -300419087 -530075226 144995029 908935551 629347176 284400199 423285637 612790531 -773746770 -320061675 -213835231 417643721 844985819 -965834697 746808847 760637662 394869764 -894073654 -377502303 -864321273 -746473396 -571423848 210756791 -457135374 828508394 -500148880 74227271 413649882 -643928650 197624778 -490696427 -165689897 -810205394 -40137861 543485151 -53558917 622728962 822399215 -380238656 632435616 493850045 -752305000 -432253225 43526925 -216348070 -892907014 -705718097 -636411281 -484042492 -522169917 568916734 175950448 -175762206 344627959 2750477 402301369 -200518009 229927755 448335762 55232224 -173525759 -48259794 -773230193 503282876 131154911 319321524 -912975844 134514921 -199368206 -816224345 82095403 -473590512 442427446 511612045 882427877 112554007 -3…
Output: 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 999233728 …

Example 3:

Input: 1596 664 -613021433 761517870 -267753406 239679070 127434603 77287001 560682428 486854167 -537967637 980063168 -824734533 924608377 -457052302 -423949342 568856671 681104823 788100903 965564580 -286023986 -427791083 865078262 101741289 -38538567 -781312894 -405639803 -704708725 -962176592 -340578309 204539098 597379911 -278204173 576267098 808664151 542474870 -922045983 56902024 244906588 53038714 -118302120 136958296 -724899595 951244698 312278106 -31081421 -588583908 179625225 -132285152 474854387 380582686 661075325 239818908 611714000 -345602480 861978616 714656770 -477786734 577948338 373613432 396975980 194873976 -238459091 -570708640 89057936 -38270893 -338950404 -986247974 835112671 -372881929 -195165291 110923946 942284024 -197415707 -772291292 -21661477 -272006379 -61343000 53990…
Output: 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 998917221 …

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