CT53798

Last registers of Cobbler

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Cobbler runs the signal tower at the gristmill of Rye Hollow. Today the books show a list of registers, 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: 3147 2395 -53436674 -872798236 -126719213 -223796633 -19265335 334873998 -475258135 -158718290 842249175 -428755151 -634088376 -913681268 -247644791 578252958 -453944276 -250461941 971925792 -613579852 506254757 842298430 -406855005 -181795281 -728869849 950811878 -249139227 709706993 101090669 -455615683 -668262587 378721048 -693254976 -667371621 571291123 -186599245 782823901 -217889419 304377917 -261237734 316461740 -306508617 482839024 770319337 174444169 -654068557 484225794 60186034 14453982 -751112680 -325702395 -123052129 -42121015 951514606 -801230853 378739887 -238069460 692874908 -301925487 -22432757 327689889 875625016 621956607 -29787136 -315447809 575177068 -552648504 560607914 -567580060 -462006315 -757028085 581954854 739942814 -511913 627964974 782852056 -979973379 -974887…
Output: 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 999999051 …

Example 2:

Input: 3581 282 -454793464 -110158921 -952186455 213431019 -679733796 -337901171 465289239 -119567544 -596606777 -411808272 892772177 954771081 -837180733 838659991 675158113 837945352 -536661750 549150377 862231609 868662973 833846808 286114602 957406486 158206939 -444992927 922062373 -689817279 -796372702 473227877 93304765 -470423987 25883470 579825372 88626494 -458346674 -726741392 205341974 635527467 453096399 -669222088 647583350 -356485950 176212004 -900810781 516129327 -41472825 -262529817 -196048799 -581106148 79251154 330232236 -114184839 452827565 795025596 451865179 -345279222 2572395 161515212 746561175 277565088 -202270406 -845508752 -774039059 918314807 211776193 433413148 -133667867 394703144 -496068468 988787064 -16370391 -29759028 759137297 102744206 716155771 398528718 -2725285…
Output: 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 999570602 …

Example 3:

Input: 2483 2284 388463863 -848128227 -320655805 453237901 -49398532 -523586277 793812195 -516173050 -260904235 -41025780 -815583624 -417021606 -569124230 -716106694 -175531955 121460988 954958971 -179476844 313799582 55790212 258134261 -352489883 230558477 95906132 -653545856 -802857093 415779242 -228169732 32919261 -650762656 481333705 537274267 818035630 4988812 48693169 -688067543 354612850 545262688 122151099 100783885 -154540326 -205958653 -7798130 38583583 884045075 -438300395 -12499300 -51752277 680347695 210805537 393847484 610476679 -822281568 -720729041 79311222 211115683 502895790 710480565 -812051718 427224640 81145209 -563995922 912541321 597416181 -921935258 410177491 661337126 765674617 -334340719 -312252392 86564175 582432518 -398413811 250137832 381475265 -16872285 -3124195 -448…
Output: 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 999615841 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last registers of Cobbler - MEDIUM Coding Problem | CodeTikki