CT53976

The Peak per Window Beneath Marigold Row

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the saffron fields of Marigold Row. Chaplain spreads the ledgers records across the table and picks up a sharp pencil. 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: 598 311 579050772 890833102 650230750 918973717 655629462 909497398 800722485 963564646 -30295989 509858044 681895441 28323648 721706859 80922850 67462410 466613534 244202175 -156312237 -474103610 -157629626 -292796638 524263407 632209605 -602078284 965693897 458957569 -686187543 -44019857 -418093003 -49691004 800119527 -856157776 -918303692 496131609 267418012 187345178 943487307 -65801261 612804944 579261300 -661782092 -571004252 -276163156 -194019889 42739692 936204895 -950286285 -725801634 -922978868 697895960 -724163397 -210597642 339590726 596689926 646964705 281391492 -590874134 -955960625 -731986381 -438843365 586626657 208400571 -574672757 -163133417 -112805019 894500441 415000458 271729268 -375047672 -232703026 711925316 -346256649 959693389 902670507 -305494644 692981582 -646174…
Output: 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 998951986 …

Example 2:

Input: 360 148 -944624974 242658704 -450541238 75612402 -857691453 -800212388 578516578 -699912104 567916791 -341202198 269040957 -365950515 652927729 -737639121 947720869 667704542 -199049920 -28900552 -750496607 -988009846 -634399256 192157025 -934690567 792241704 96717680 -316164104 -298801880 956505752 -393407884 158326938 -635812816 748812296 -592928814 196666245 -14524782 -920324724 -363646845 -312253580 470921904 -974406300 -560315212 -468201875 608343100 898394186 68046193 49874340 -500689308 -981372809 -67773902 885108323 -42707086 -623781595 33444737 -298535832 -510009858 -923555407 -461120063 -299155412 -969280798 485613169 222278241 -695696463 614716031 232885995 609046685 -448668968 79443429 -800691300 -277988597 772776026 -239165295 889906417 525397871 -795215682 -710832442 -1210235…
Output: 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 956505752 929009682 929009682 929009682 929009682 929009682 929009682 929009682 929009682 929009682 929009682 929009682 929009682 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 956991747 …

Example 3:

Input: 742 474 -609756389 316030466 105278640 -247040611 261025617 -573475936 -171074798 -276420638 517443901 -499089070 -175783260 -361650684 351038488 -833613451 906608686 -124161706 861497066 -310566583 909793622 464585233 203897920 -175635128 36505843 827982032 -275043749 -626253958 699863016 -757584290 995278574 88944334 -658102235 733620458 -698153188 905724650 -981247012 -938363554 256915344 125519720 781719413 -939081530 -961606420 -882086657 -411572937 214566945 939441260 -828733918 -290991937 -287922549 -914557049 -539457520 681216656 57120003 760108957 -510043352 -209069 303570476 385539495 298795707 -744702849 19681952 -648758334 654421316 -293470806 706815717 243955240 179744843 -189077310 -440817658 -469628529 461370738 686210359 -414301695 219104555 -287860559 2501804 -396361999 -9…
Output: 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 997839102 …

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