CT44857

Ranger's Ledger of beacons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Ranger runs the mill at the lantern lake of Firefly Mere. Today the books show a list of beacons, and the numbers must be worked out before sundown. 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: 1054 1003 537253770 -527119974 127714617 284954118 -578349755 139282895 732718951 -832347744 63499435 345774997 -798812686 306277551 -461981544 275320412 -9550284 -703673610 434104581 -363569517 62030643 164384719 -29605614 -591841450 479337580 262211615 -893824232 -656074088 -666389908 -493053155 510005298 -185710004 -68910012 557614822 195639195 20071161 -247636897 -696817496 -979387942 -924573227 -151011282 -185772556 953925992 623583072 -561931322 963813046 -382299784 743022849 193112170 -817392083 -498789358 214689488 383402235 -931466983 -554928063 -861066127 297565804 -64545568 -77047277 -583409049 700291508 -784931195 -608644298 -367160353 -886517528 799006111 -696719682 476052023 -931615605 -114218297 229299043 75174556 -836359861 756014393 -910331368 -20980839 -433887633 52058583…
Output: 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796 997535796

Example 2:

Input: 808 360 598240996 -794745588 -458201567 -849307270 -316006820 -797169285 609409581 -175747066 994737408 874313948 -101314410 116607638 155439794 -543779712 -379191653 481073155 171168391 651333674 507064810 -338796449 184808493 298339227 -431343825 -52083669 -959794269 469641789 -609488839 403313898 173127405 -549831773 -524183954 -136096540 -539189447 908522258 641998383 141104772 -262158042 111200789 -757994558 663379771 -666408004 -654536546 -95574288 -903616032 -315819723 61884608 773949555 -883998920 -835049441 19121100 -305568348 408100419 426467933 -202472578 386663602 -296144809 -924850382 250084179 -888881697 -469648006 -841015837 -49304012 -331121291 974003916 729964663 453098009 489757577 -397658338 158006890 -470289549 966875346 773206638 -183854989 -831271902 677801306 -147741…
Output: 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 998405793 …

Example 3:

Input: 2314 1372 -572335074 -718261988 -172222474 -194580169 -98919971 84825047 -557549144 187933612 235407099 57963962 998783733 643383904 191263080 -3059766 14408791 351452705 -240718704 962610586 204379209 -293172635 -831239054 990763651 -771924336 857242353 -745069547 -785265384 -945089028 270551198 -276148035 -589336590 833916476 762308881 434178838 -134614034 289027520 -763630940 -133325671 973764154 257762848 -534973100 -389328202 -233366226 735775420 710233704 -14042660 -788318079 -256617096 -857698273 929020923 742906325 300395899 485249952 704163994 -220741799 -782681977 496899023 -42737290 517533475 -769023365 -56652189 935167735 174294585 -535230720 -839522441 909441619 -674619955 463405345 -838976091 975413750 -731785931 13119667 -869737188 924405532 -290949522 976330854 -64485983 43…
Output: 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 999123970 …

Constraints:

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

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