CT49476

Sable and the Topaz ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sable the dispatch writer watches over the maple sugarbush of Saprun's stores of ledgers. A careful computation stands between order and chaos. 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: 2545 304 -463219301 832579111 -980318442 122442765 51472782 948562022 -93388249 -582141008 -695659686 -518137076 -57550527 519081855 -211930441 -89640715 -523471245 8700928 416839481 -917615868 -606708502 -270324925 993708853 145266130 -228768943 -350980858 -16715927 -91103756 641217704 509702173 315802861 658325691 -191837589 -697107048 -889593829 -716023074 -622704780 -379851410 641983996 287766754 745170382 -344759827 369216684 -187052546 150647559 467169307 -121208266 -345521046 -335188049 49614493 727864435 -841860946 -919266003 -468390593 -795028460 -707686233 -138958396 449009509 24317022 507862451 -377354003 -430450299 226019839 396174398 37906993 713118862 -823708293 178687436 302131769 -956980786 -286912706 -619167522 488726627 -468545274 897753813 657293311 -130498858 -53703727 …
Output: 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 998615852 …

Example 2:

Input: 3223 219 3958138 -667770963 -812154018 -393037340 782022227 278442328 -884995285 127877141 887279680 -223499446 97713320 -996207765 -874078555 -54104068 103296116 -924518012 -853767710 911836511 -880660657 597748973 946525621 109120765 -890603504 925624212 -608911310 943506594 460616749 -519957428 494415550 525833381 733436107 202915945 -955932683 245978810 362027016 785451294 -753525912 957724831 -756371557 29011423 956224501 676316732 1946773 166993224 -544673327 -290131113 -277447128 497919134 876531530 276359228 -585133908 -550945279 -495556940 805287599 570825535 -202573992 685711689 -663028096 -230051912 622940578 846669916 -605236539 824897199 -467428720 -439883848 -142147087 478461761 213017785 151911031 205258317 810075980 -800832441 466195652 -783166456 461763691 -901054390 -9083…
Output: 965848257 965848257 965848257 965848257 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 971843398 972260392 972260392 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 981283004 …

Example 3:

Input: 873 529 -609309157 744822611 -270032553 -414474026 -318520512 -256385859 -686389648 -720077433 308268691 705715331 599248646 164568575 486105532 -707388886 99001873 -630723744 -434057804 -900780973 -721895824 -366283871 -672574864 744882836 -488283538 468573103 -974356384 576457703 78018557 223920461 393240110 507931362 162316235 628264610 -929786764 -369990863 655604409 -816070232 -155159063 314399135 -829434692 538498750 -264662086 543225354 322475587 434898781 -225058098 -285247244 539378750 731334920 -811758362 927741987 -619467966 873787441 717913568 757165827 489225848 982880716 -338008590 455200057 -557041738 547433253 -728111481 961702744 956575319 127425475 -667795926 259297993 883009040 800186147 -897435885 70491988 -36558088 785003450 1530888 -58937357 352420137 -286066302 69607…
Output: 993674923 993674923 993674923 993674923 993674923 993674923 993674923 993674923 993674923 993674923 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 999715698 …

Constraints:

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

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