CT46898

The Peak per Window at Driftwood

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the quays of Driftwood opens only for a perfect tally of registers. Sahil means to find out. 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: 848 513 -327318476 502927675 198507275 -438336377 955573260 -843522797 -989196975 -188573441 91847782 -848255319 -937874348 23611395 19468672 242267332 -868270492 -961477251 -430896035 -397398020 756824607 214127549 825013455 -610065944 296800395 -899587849 768501742 303469998 -527853813 -985419367 -122051729 -510347053 969112199 15751324 -324136925 -313929231 -175493920 734730838 93865790 -253308270 -24515152 937592313 -813359289 -413944130 -896012660 55016877 -191997796 -825652255 -985701956 -947262072 -212442101 884666906 283818284 -956345158 887558109 -308449564 38808440 -6077077 -646357288 -413270463 -783467463 -638564960 -21374209 -783915343 -218366382 -447189469 257622264 763862879 677086927 905989682 -472307681 445882636 570408016 891933766 -137009964 304885748 -947818337 -90212419…
Output: 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 997732887 …

Example 2:

Input: 1591 1035 -971102199 -617396123 -596931833 821877533 -580599403 -586912878 9677276 -490230151 -447499898 -617280860 721446009 124324957 795911388 983943454 -113864931 -500276362 -602623809 -175211391 618025075 -6172840 -407765323 -721829375 564506339 169771197 588037751 -451032881 965815890 -688823801 -23240706 -757749753 364926780 -47653588 64211731 603249045 -388365623 23861086 -823521663 500051952 -790022700 199535272 -868842547 -191224837 906538681 -223941831 -600634087 328400280 279808406 157511536 -887517634 -605599291 -252548943 -877020068 567866681 455728388 -520853452 184760262 -990550687 381791206 -940210054 -854325047 994973820 727786118 -337046660 -118663299 796497621 -61269268 -124343918 -459108754 940041780 511768622 -560619266 -11497715 994064529 -232587840 625463411 -431818…
Output: 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 999818087 …

Example 3:

Input: 2020 98 -566504990 -590338817 -673052968 -205603317 -898857486 -506919820 -437646063 299971631 -307007004 298257848 -223605700 307019956 202433592 -419442331 -461032822 395229353 885821327 169149119 867343542 -474051055 706973764 -918527800 -346397650 -805192730 -72929093 -128055310 24394282 -102807937 -250855187 865023867 -839424507 -338259907 679654319 702513060 -58220499 673732351 817044882 312109946 -488921667 589348444 -467543485 -713389740 -216389665 37348429 -227236499 -378809803 -12835793 184306173 925105197 78550840 -615795722 389915442 -464977969 977605208 -500266492 553758272 -555280868 19033127 619598348 432578011 952177062 968223236 305404529 -507361196 -665685238 -586353857 442497676 -594555015 -761708801 -359710275 -475722375 -359868053 45830459 -379508408 508575650 81123453…
Output: 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 977605208 968223236 968223236 968223236 968223236 968223236 968223236 968223236 968223236 928491790 928491790 928491790 928491790 928491790 928491790 928491790 928491790 928491790 942885176 942885176 942885176 942885176 942885176 942885176 942885176 942885176 942885176 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.