CT51310

Leon's marks Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the dune sea of Caravanrest opens only for a perfect tally of marks. Leon means to find out. 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: 3597 2531 -690620495 -414235531 -870795905 -466385621 230007324 701598726 -576445643 523117749 -277726079 352748323 -514150961 -228369332 -603794103 240057157 -675138422 -888271929 192228308 -194294504 772383080 -588296944 978135159 92157422 -233932816 -202675831 -777800175 735777587 -606582555 -70931346 -194461576 -563924822 374508879 375040335 665621917 -526315662 190004818 -883820934 879916511 865265897 614141886 -309715956 -150216596 -234798319 266906963 -486783389 -33453462 -427799928 970572440 -588624916 -857642985 443240358 -367805880 863413809 331745514 -258839841 276412317 -294167038 986820425 639269328 -514044065 -715452806 945028743 -40370551 637899118 925395500 -15380803 360282058 342413185 514247983 -976300783 -855027877 638537121 37153162 -132241336 345604675 -938175472 -7847…
Output: 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 998360310 …

Example 2:

Input: 3207 289 -381073006 -654760484 -574985474 682199724 444726997 -439402898 423973123 419025585 214485130 958486818 -766797276 -838254269 637754012 321809891 -555174621 -389997662 925975915 -470288626 -149714210 730693330 -330782490 -534434156 376392987 -941387900 712008040 -908396194 -424984744 -777912372 215456487 -364983925 -693906186 -807812750 217284055 7448595 681470533 -147649552 -172314251 -991949691 -620625017 -6027878 -813424619 603421237 -891107648 -379592764 902008921 904298296 -915820112 -574301232 -135780486 830816657 -517993205 -521821094 58967712 -763834516 -619634151 848014335 -220338491 678669523 687411012 160715505 715186464 -653908328 -325155723 245398699 -850837728 -504369334 -863629804 291185597 559768310 556756031 801129865 -802980 431871159 -942449805 -21855318 4834386…
Output: 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 997090390 …

Example 3:

Input: 3347 2265 582546915 -262812053 153589965 451449172 -193195894 782394448 -426513897 -447224471 53534482 -436898259 -751584549 -993186021 -159228386 -487944287 -625860441 -113345651 -744777892 719143395 -259456763 -400932751 882105691 -55717567 -600777000 135224809 642367198 721570707 -392408812 821381822 261121559 -182626752 272768704 -961464714 411702164 -307056904 -243803844 177792378 -918695941 142323525 -965107162 -840010526 252070804 -17568977 746275514 244607266 644263519 -738951584 332805530 149462908 -325590199 388817170 163451539 -536298385 -199472744 56378478 322750318 -562297522 -660339534 598282589 143770801 -900498281 590366185 -306942921 -469279856 -378047961 -124332614 653581784 -813413081 687928899 -147564759 70264837 148787917 72653142 169751442 57549366 938741761 -70769961…
Output: 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 998557354 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Leon's marks Peak per Window - MEDIUM Coding Problem | CodeTikki