CT43441

Miller and the Gilded beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Miller found an old ledger of beacons in the stall attic at the clockwork quarter of Gearford. The margin notes pose a precise question. 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: 2493 1702 628887545 -624886442 -794174960 280748386 -178217748 -92361992 -249546742 616688511 -64248448 -41060794 435193945 80525211 862569089 611409611 619371699 889684190 -855162353 483559252 -503236561 1793498 -291910216 -814017484 -566373902 -700989866 722415933 -718536040 118525586 -517164914 -486667456 -385858027 -316804428 -667810576 -855953872 -714272354 564694296 212852923 150880240 49677491 -28167413 -771792997 -338666814 28761738 723047033 -176775139 33628978 208415617 924450427 393026838 -601474344 735308792 243060507 -874721424 -856024831 48329836 839499691 -223100598 150103560 931450119 213164987 -550168444 -120474716 835099149 -844738739 -878551528 -28813002 -720284329 -143143100 -439719956 468068768 146250191 672789374 944976224 947497234 520505612 -269269031 -202496444 -66…
Output: 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 999957036 …

Example 2:

Input: 1026 271 -467890964 -590772011 -324541537 478541616 691251194 93459019 496117845 -48745930 273681186 442023568 -408371006 759798402 208516954 -550868424 -380723443 -944281140 -277411080 51661034 214170849 509127504 -104005041 212810838 -645603059 -217768583 962011151 803253706 655087383 578661846 420572781 860883221 267237956 179694867 -747392116 -465373817 276816496 -144342788 24748942 -850882228 -406763095 326089019 -933854990 380814553 212935395 -285444215 -786387891 -673877246 -747326186 147389211 -770450262 -408926369 32387975 616565158 671790697 -642435926 856319078 -84478608 457809855 984873857 952863659 -450730231 -389316005 564829263 841805244 534286540 923428136 987093419 788870019 287444861 -980720128 954853165 -196583661 -188965571 797541678 -963169330 -977443595 -667884999 324…
Output: 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 994445358 …

Example 3:

Input: 234 99 921035645 -897181329 -973430016 -770155645 546978256 -832292694 333366385 290233464 -144442891 -263169513 219437387 815879022 -617596388 303660428 -746625465 829809640 510492521 430875140 -504871360 -970026803 179309362 711284166 -29806608 -318407247 800266323 -566878803 328011671 -908391666 388288969 114240183 -140988627 -988084513 -184531038 -924841739 49039522 -680021551 -117541779 428988576 -39371453 531990454 -280500213 595261971 763898630 -162239340 -524790262 240065337 624934543 -694794336 -429321839 -258325495 594009334 401501038 -156602928 757363260 -921363995 -879854036 89643755 -705603287 466532 -914157691 -403553151 493682189 517648662 784152565 -426435890 -956873398 -578421373 -492491265 -448733296 -449541018 -867738595 -859959026 263746253 170810559 -207708807 16124522…
Output: 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 928079152 955033969 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 978887038 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Miller and the Gilded beacons - MEDIUM Coding Problem | CodeTikki