CT64537

Hope and the Whispering ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the steppe camp of Horselord Plains opens only for a perfect tally of ledgers. Hope 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: 2228 2216 328846817 -674231415 -69468748 -45961815 -579695187 -199802640 645138204 722999563 608493189 -401561826 509831617 579400824 482760326 81706616 477039613 -712173216 302751507 271728184 -511114579 173236616 687976520 555745832 884473283 492982737 938940780 928791939 431592768 645862219 -259030542 293403489 577844280 185719959 492410914 -927474684 655558079 917282079 -931585902 -420379307 259621069 450392417 898939581 -66407497 -697289803 702751006 796123113 -196395931 234167284 -934151678 875332072 -222392682 -867907469 274646830 253414164 -581409497 -668026329 -223481058 -959299663 979968646 -917256751 193395021 177589697 150504303 -165766836 386987608 132223129 52886358 -131584309 -741918340 49579018 69640443 227854944 -851287124 966213611 106162162 -776815631 -812320170 -9843455…
Output: 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603 999472603

Example 2:

Input: 1882 412 283400309 575479028 376653817 -6042633 901530726 -615534310 -521352013 609318071 -534725493 170474845 815312749 988485883 869710799 584785895 -635920889 -80477544 -321561457 659556592 285970472 634254966 -657788969 -157362088 -372460247 8131249 -666270097 -531225837 527411362 -485264029 636482431 -923176757 -877532385 309261409 202297698 592570724 -863552382 920958582 170788124 897606155 205133098 -83968531 -52937862 102160638 -900664201 -101952067 830014544 -186290763 148602637 344727572 948491408 -725667123 98886862 456048643 98007604 -217842604 -266877130 279648285 -542949146 576002001 947976528 217612579 881922330 -159534381 -103570645 -306070836 -244294801 152786885 302914493 857908692 642478846 -504813775 -333132833 -16525441 -145357152 451322357 -941629465 -911006931 -76061…
Output: 988485883 988485883 988485883 988485883 988485883 988485883 988485883 988485883 988485883 988485883 988485883 988485883 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 984319124 …

Example 3:

Input: 2018 277 -62360589 396108441 -64590454 546114011 350106269 747849967 -804681079 651111097 35942637 724455365 -296856862 747324643 641626638 510295945 984157129 -359655018 -12112495 466426473 -644166747 808077967 -555242509 648903753 -181350399 -122001427 -270505131 -30787768 794157341 -573058270 881934484 -86412204 799467569 -703365115 -869769423 693753139 -663721438 262426452 -143811820 -509241451 62792901 305401811 -86058849 531598592 -671093414 266908011 -709074006 19425700 -166736230 -165360398 582480857 732067790 269883851 -376043619 4970870 -758374834 811835129 183661265 -258852064 84104437 -500069170 -994563337 -255731817 -678479890 924139164 -610236652 70305795 833530115 -914302765 -219007138 569956480 -450973632 -691445565 872569910 -919740691 -685648028 -831560543 -89876101 95974…
Output: 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 999019731 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Hope and the Whispering ledgers - MEDIUM Coding Problem | CodeTikki