CT58009

Lata's Peak per Window Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Lata found an old ledger of beacons in the archive attic at the savanna camp of Amberplain. The margin notes pose a precise question. 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: 2485 696 171409115 -88989023 -465028468 421463179 -910741897 -593278099 729644627 -203567728 897698576 790993964 812985567 421775314 -459347117 -166840108 -68692441 -204729380 74715090 449560083 -960151626 -872388302 347028341 412035788 723164356 834670312 154629306 244502149 639769797 385907750 -299783468 -634392602 -968182006 -941608070 -316322447 147465993 476944455 -90726241 187507524 -915898722 -352253985 -716944056 344522456 -272957696 223141265 834519731 610237570 -349054607 -520432236 386089813 -273424382 -688734756 36562566 -792627300 1498543 -321337938 -83378276 -73736587 -579212646 -787879788 20060677 -615300135 954466390 878314536 -434649780 -890330853 990070888 -645168525 -995312138 656713729 247283872 753344688 333174952 738611586 738800652 299495838 74206535 74142845 -831550…
Output: 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 997072657 996600005 996600005 …

Example 2:

Input: 770 59 -504615854 -376259268 798151575 243371007 -673032828 -252418722 -194308875 25455073 -390583631 -275144761 -180751167 -965476223 -409188052 -728646185 674234966 468937430 -453996946 391963103 -937881452 -299039836 -271163201 407215073 -845234323 -365421589 717937888 829984744 -409312074 -911808476 224071583 704833494 -877089874 503833177 -730437275 179167223 238965831 -626090345 800881593 29242608 973750253 -135676863 762862988 948040207 816283377 834609810 -102389682 382786772 606909491 995162394 -790755764 274820061 -131959828 905225295 632363032 798283276 851666705 -620575661 919296365 73222338 -686799909 -222491280 -979778142 934522628 -929161975 -486440303 -301225462 -428259913 -326765161 805971365 211119631 -896839673 612671636 -746761701 593532023 -776003119 720378410 74145686…
Output: 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 995162394 994711542 994711542 994711542 994711542 994711542 994711542 994711542 994711542 994711542 994711542 994711542 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 996581256 …

Example 3:

Input: 3040 1759 245420460 378326040 32083400 306935052 934496078 924805005 621296983 370203738 -974592355 -817283612 -112183796 592763430 820716920 -317294082 6082722 -915989246 -637729103 -489695311 904013125 -352620845 528317531 360642015 -693749477 712222881 615410466 180065624 -375328754 750566216 -993458430 596273199 -881612603 -738364277 633003250 -53681734 -560452120 247308387 -78937428 21877327 947762907 200035325 91569798 890148763 959115182 659702963 -876264286 -763590231 998796751 793085096 559155428 478746274 501347864 840684318 -622551477 337788890 -710822821 896533779 438650667 -981357700 81355341 -893132053 303655645 -591357341 391187974 925956032 -393331497 371311981 391633633 -927104283 -794222506 754386010 242812143 237202085 90146392 -102382542 10886620 744348563 -687932122 -2…
Output: 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 999429243 …

Constraints:

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

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