CT44642

Sara's Amber ledgers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the heron rookery of Longlegs; Sara weighs the day's ledgers manifests and starts the calculations. 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: 3505 2038 -785105629 -558812722 -266760449 -803241590 -456941422 516347026 -610915288 479568512 -90858161 -524791677 128520629 -669478459 681203200 796220200 -15043082 951773906 -637007190 845723120 -232489761 479474296 -928657882 934181972 303063147 635838745 -34070818 -190642066 753610287 500560460 651676057 493418675 -395474412 -500191093 181548966 136752079 -29890083 -565191133 -388268776 -505320227 880614816 51378781 -565634575 -938116387 -176594288 872634392 -415741728 -198930049 -230362353 -788441767 362784002 337662930 603667978 946639465 -577447372 -654635105 762175021 -518387492 -973866229 819025277 922477734 -645403553 -963168876 911731562 -616470662 708945558 -583408679 334570738 -21539113 839909641 182635042 -896167337 -898262557 -134732308 -485660159 -364052018 829674411 5986…
Output: 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 998954743 …

Example 2:

Input: 3619 2660 -463753975 -109399708 733426450 -492316317 -540132028 78415140 336086580 -535851929 222543324 -886056175 -737519209 -546466282 -710799316 -201977489 -153390244 -513387314 253661617 285269044 -24074667 -785738565 -805328821 274364538 -683024399 -903570711 -577954315 -722497775 856447505 -648718938 -303590048 331471355 -639729359 -964226448 -385140618 324054036 -813170013 111738357 -380403873 -936971049 -789527202 -575273847 -500095083 -517153034 395731153 -424388560 83183651 -628563533 844032854 110237720 374799640 987090540 -25070288 -902111922 -653623269 -89757757 -316128171 -759503172 526666250 -691486017 741036298 196349894 -366720162 754910152 -231276170 -49688949 -688790450 97438108 497837194 525440272 -445720412 15347442 -90184697 167362921 506877986 988364881 219402326 418…
Output: 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 999861112 …

Example 3:

Input: 110 17 -542603603 -146281691 401881216 -235148151 -297250498 -940943415 238521746 -473606394 610890517 636364130 -158256627 -813532651 558305999 679237903 369425704 -664800230 562489663 -181795070 996223386 463114640 106402656 816863058 991082637 891052215 -371158898 241498141 -777898750 627843913 -621728910 -435911650 132522278 252718172 -966485731 421301394 -750292181 194495273 42768090 902601622 817773466 91887408 397577478 -452509883 -773021980 -47581275 -371858687 -475147490 -609581711 539848560 352719275 825031566 -614319974 122979726 -312635046 999487290 252242165 -77026504 -177991854 666587988 926261363 792550871 721113499 664593693 740879171 -184443699 -211947898 789728758 -231395942 704892900 507914728 -317615579 876280903 -850933691 -320621485 -504651008 -849195526 639346359 693…
Output: 679237903 679237903 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 996223386 991082637 991082637 991082637 991082637 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 902601622 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 999487290 926261363 926261363 926261363 926261363 926261363 876280903 876280903 876280903 876280903 876280903 876280903 876280903 876280903 876280903 876280903 876280903 876280903 829819063 829819063 829819063 829819063 829819063 829819063 829819063 829819063 829819063 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sara's Amber ledgers - MEDIUM Coding Problem | CodeTikki