CT49767

Pavel's Ledger of registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the garden city of Petalbrook, Pavel records each registers in a worn leather ledger. The guild wants answers, not guesses. 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: 1018 545 -43714963 550645495 -121385513 -508488929 -520634201 -556093132 -237186687 973531506 -118297134 -285316923 160119146 997377776 166072996 -649472725 172796021 -473028131 506890484 -465142061 932520449 522407550 -971832315 535615974 -857619744 -289868140 -917709801 674159235 901541831 806496908 153583222 761336148 -283935238 320205423 70436373 -340313400 -432454716 -591904611 906550860 -817972693 -944813498 -855226263 -638321757 942231746 -177067891 367622609 -449318164 -438474693 520687410 -644240652 702173196 -360041451 -186699400 489797971 -124500194 -533469637 -700588306 442770239 981355815 839380872 -105394435 207552086 120782801 -338612516 -830276260 858027080 -907237377 833650475 -89930478 -939211187 88959881 -360416605 -454770450 67676041 468222814 -532296600 648808304 14113…
Output: 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 998047607 …

Example 2:

Input: 1967 1580 -550345528 -729502316 7340608 418715500 790626860 322846801 -901381614 -310838739 -554465249 431313920 -230159233 -714938859 -745323979 739100167 -495280197 639238497 424268257 -200415403 -579086012 -776643372 -125242286 -999806588 670627229 -905939205 765675198 -363707664 -136683405 536434683 492290286 -573220983 -962041195 435222118 288846518 -546449660 701750762 42160124 -945453927 -468195820 -422270886 699058873 431129083 950239116 -515621905 18022655 102043134 505974626 -701876467 -11164984 417734425 -513494238 -711068224 628088603 -717744107 12331715 792190376 275822641 -558706832 119119733 -267295529 -689213063 -496604848 -484672786 134492739 237304906 -780645706 494667620 -777377145 -839566791 -968992271 -789286721 -521457187 -988690988 -565502878 -838708678 -932362740 -6…
Output: 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 999852377 …

Example 3:

Input: 1776 1018 -850133455 783724077 -133572938 651152616 -569212482 -720971227 -358405340 -200449137 -911397309 146943029 880213745 -997052196 57570512 -10181783 547768023 767132354 957104008 -7337540 843989706 394427782 137204050 -142055419 368243890 -226468841 -884690842 370539090 -291938119 -812006347 506874866 167281334 162780079 969781894 -921125174 380597909 -670401149 144807672 -694845571 -249215833 -366315361 54816232 -501490833 -610158995 377732017 -166981797 -204262125 -779377967 897211844 408504495 709218599 -683979967 453957620 86980716 -354206158 101792496 880673955 -23942576 288348614 514493354 -809873271 804607089 -789351050 597937516 296131333 400151471 -542699006 -250047108 -886206191 549822306 131215533 -485253685 573371020 353410630 -921846670 534119896 -834647536 -45024844 -…
Output: 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 999615798 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pavel's Ledger of registers - MEDIUM Coding Problem | CodeTikki