CT61197

Aldo's Whispering Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the desert outpost of Sandspire with crates of beacons, and Aldo the tallyman must account for every last one. 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 1958 46757941 624103780 572332301 -615406641 812840033 -21453767 -226549593 -877099464 -201045137 5303464 -459035210 -381373310 27785749 -503643680 847076742 749324263 -506206388 -139256000 -687033727 950275312 -451605179 -40003477 -535873933 -878710404 -698894589 279837228 450003511 -227887640 973743421 761073893 747047075 -267543196 269899175 139195987 -850336978 -593762354 34252091 52336793 696795272 64085623 45676508 894814901 -339135905 -347257105 -138796706 -114004896 418129541 3175288 -221674902 998623885 -510143046 -929726999 -117130868 807046570 -699724268 653848147 -121165654 612312197 -760127898 -968961813 -55824186 771643950 44482474 -874128013 191425738 -930403576 -795438894 -147656422 920416410 618221609 964320509 -162309128 715761224 -919150275 437528812 -657118905 6576…
Output: 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998623885 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 998522248 …

Example 2:

Input: 3364 5 304792732 -698343608 571419903 -574091487 510453836 -848528598 979451699 455965390 566239270 -725076336 70431471 -928438981 896735319 510297441 -845337631 922932986 -588062013 -998628547 -33123536 886226105 777723092 -583682057 686396718 280045303 432059949 -86074930 -125597628 -189399184 92676382 -856163633 306207180 870837524 403073124 -583968022 821229568 827681469 126091367 -294679368 -98666928 762257975 -669652130 596138316 -770442079 -293378872 636578164 314703876 -279077882 -652647123 416737838 483700043 545510722 -857718294 962592293 -296155763 813469764 662874752 -839850343 695499628 -118988954 651344254 11191660 -41837685 -21073404 52887943 972959080 663558192 372298200 58099230 -599480896 -689980566 963800483 -748460027 390847766 51561197 892672227 -922866437 -203982378 6…
Output: 571419903 571419903 979451699 979451699 979451699 979451699 979451699 566239270 896735319 896735319 896735319 922932986 922932986 922932986 922932986 922932986 886226105 886226105 886226105 886226105 777723092 686396718 686396718 432059949 432059949 92676382 306207180 870837524 870837524 870837524 870837524 870837524 827681469 827681469 827681469 827681469 762257975 762257975 762257975 762257975 636578164 636578164 636578164 636578164 636578164 483700043 545510722 545510722 962592293 962592293 962592293 962592293 962592293 813469764 813469764 695499628 695499628 695499628 651344254 651344254 972959080 972959080 972959080 972959080 972959080 663558192 963800483 963800483 963800483 963800483 963800483 892672227 892672227 892672227 934925042 934925042 934925042 934925042 934925042 920886083 9…

Example 3:

Input: 1984 1139 -585493333 930722025 -566087411 -473391148 -479414358 -959118551 642609224 66286985 -798616243 -57759989 -851450574 -569676954 508126884 -591261596 -559013873 -327629094 310444159 941998011 -410158341 221113561 -625346965 -841834483 508363041 956392911 211974275 834889092 686771536 796274393 70856204 -422296213 52918346 -265211942 133826011 -31861238 133766347 270447294 -80404958 630376672 -884559331 -798074166 -645191093 -921250337 -160072235 891737852 -551735715 -723977322 -436379668 887896753 -478982625 -509278055 327070264 -825974847 -305396647 -172878004 -7338490 729408004 -5287020 -832118052 123692294 6202494 -157059743 -316567793 350503956 -444138388 523555148 896559124 991832394 -757840996 779219685 175709027 848863214 -849150861 121667027 -351081375 -2247861 31673614 128…
Output: 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 999482126 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Aldo's Whispering Ledger - MEDIUM Coding Problem | CodeTikki