CT57105

The ledgers at Reedmarsh

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the willow walks of Reedmarsh, Seth records each ledgers in a worn leather ledger. The guild wants answers, not guesses. 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: 1672 733 -361544190 -138472729 561824729 -86634973 -105095159 -728767812 -602338686 -863919147 -205594165 81169089 943656472 268796328 -871741520 -426220669 -63162407 -148155372 -295691220 724371680 -867781425 816654890 -218830548 -573735154 235488736 -207375053 -307990324 -865214418 -954864935 936407382 302340117 165115859 -549715702 -387356391 942539570 331911836 -629620269 154213995 473256428 -497152376 -290794099 -221116709 613756819 476102140 -703367332 344223599 -836274905 -392636861 516403239 523135615 979294045 -64213307 638826718 613379796 257042501 524140606 -552690722 413986066 -350450641 161609296 966589283 277713993 -589243369 -889673999 -397700461 396248606 -137499223 -248173826 930858040 -695812878 649151977 -79833594 977164386 372772879 332083930 557890756 -340638772 -21225…
Output: 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 998313246 …

Example 2:

Input: 3192 2333 -526579629 -647823337 -902239296 951361075 -692478664 27283329 -629539921 499212273 897682678 -136360730 -560136318 -946166035 -365126707 529760515 -891596100 629092603 253775713 873358785 448970029 108361598 648924878 -392589578 -867098679 -16037675 -210527637 130226800 -396681149 -340687661 174120888 -664842714 929083805 707097311 759728621 751588335 -258449536 -424790864 477279708 -220778704 793987324 -780006352 -338222115 815648734 -346299680 -710020796 187844638 -973661443 -832177135 -342885577 -493665968 -593084758 963219436 157466443 -324720833 -702801168 894857962 593984541 -961766201 938386388 927223617 664012072 443808782 846612736 894184720 -201600724 317503658 202748104 238893068 663242829 483653948 355771191 789995401 -51425115 724218845 -613482875 -989143968 -654935…
Output: 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 999964060 …

Example 3:

Input: 2384 651 925005605 -978903461 -487086922 -411455747 -175159291 -105152481 -347412101 -834129400 600260055 -862989622 -928390177 -66528908 167094367 -650386295 528854214 -415470724 -550897510 -499701890 309374466 740160881 911975989 -502023502 -693998621 -488090497 -486313589 542364100 307011957 203488790 414990428 527507419 63464716 -97616246 272456035 -594517221 119334511 14146119 -940479969 466258140 864684193 -845357132 163549958 -837474259 624660057 -836790005 654043908 -597418871 -421218852 769535854 -907534796 -379135842 -682636008 386324859 -25250149 -798392078 912661060 -247140338 891071951 -386060997 -398360045 350561557 829847128 894567751 -814156654 -518701115 -49809632 450304606 -205505932 598164398 407100710 -807253126 504640897 -197864759 -668404865 788897936 -964746186 -8298…
Output: 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 996576533 …

Constraints:

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

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