CT48149

The Bloomhaven Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Varun runs the bakery at the tulip beds of Bloomhaven. Today the books show a list of ledgers, and the numbers must be worked out before sundown. 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: 334 329 -100352613 981508718 589326712 815207629 991968546 518144369 -93730981 349669915 -758988127 -364788595 836965329 456739587 -855461605 90153396 591199347 520905126 -908535285 -311270729 -786811534 512580853 -270493599 -447130619 -763544059 -710863329 445600426 922616139 820189241 -338461210 -272770117 720157295 230331793 -993378403 -943859849 -888843736 984405683 838996753 298574214 -199053360 623983972 55867197 134900043 46629498 -813414732 355675968 -198250508 433547877 -501739445 -885860184 248623974 -132259127 -152691648 463825497 -478499912 217245576 -479382148 577712404 -144744521 733339095 289822264 701583497 136326173 67138245 -510052899 -195703384 468550604 -915497959 -701098878 -809904049 745957889 783328026 -708374584 -349518579 -452282474 657182598 -80319903 -986144869 -…
Output: 998659217 998659217 998659217 998659217 998659217 998659217

Example 2:

Input: 500 436 -454848923 -747708163 454776275 -578581071 -436517416 106617041 915187410 -250271410 474762850 -203890102 867984021 -294100152 -339926586 -432747325 639335602 -102778256 -906497542 829560434 606043674 -160114337 -775515234 483155957 292446094 902677228 494410103 -641461430 382007303 -338083642 845828920 -542581769 -55191597 -858778400 520934143 -627696832 934894668 487824587 -678354151 856724643 -498783760 64236582 816436776 -266581083 688012517 -154205923 -501886704 838793342 411974447 -9363525 -861910019 -446105978 298126533 83891841 349234297 -699674312 5674439 -227479343 -186911491 -823477050 578998873 604772909 733844512 13692322 851533195 132278553 -117724962 15297711 908212363 -862616816 -239935095 466577827 441647960 90530327 383719977 552473915 -43410082 -738088666 -146967…
Output: 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697 999441697

Example 3:

Input: 3935 966 -700728845 -671622533 58207380 -64537694 -682078872 56450894 -500925389 -215343766 -382923401 775880108 -88899718 -552609995 -412382026 -36955598 -343753951 274845842 182009005 -118388131 332042452 1822179 678376270 313282089 949145859 -325566603 -448678712 245118401 -883071924 -829142237 -204655190 163571202 148524253 -374870843 588210775 -141709351 777047752 -453165273 849336350 -40781568 -443433085 -358916964 -595904528 -113088709 427027488 81387003 312015053 -352489051 -652146219 907575961 672040112 651856850 197028396 -849838902 -212205553 198994753 998382767 333029474 875149997 729923706 -295070556 -922691634 736921530 18378060 -774626763 745646720 -128417896 -665621963 -217989135 114041160 606487070 -902900788 -566999802 931650774 283867857 780013363 647920323 -111261335 64…
Output: 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 998382767 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 997265518 …

Constraints:

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

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