CT51269

Emir's Peak per Window Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Emir runs the kitchen at the rookery of Crowhaven. Today the books show a list of beacons, 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: 2831 2043 -407118776 -306809504 -682534078 -235073875 -835482818 886157159 408520351 140928496 -46318820 -956030720 978172503 -61167129 -956258854 -472615562 710198511 -946141100 -862026807 -343803365 -913003611 222128082 -690836263 -966535025 -154639584 562582463 516263668 792880382 348360094 168888495 -937081411 254594568 735511390 -742075283 980989110 -900852753 477436162 -611594705 -576007013 -892751332 397185036 286911801 618589789 529017620 790975709 197885682 604324547 2987856 629285243 513872626 233103240 821772111 -769149452 319338764 -384857051 -723030013 487247137 569736760 -567879408 -930614947 829546509 -549880766 609405300 -643945769 -233930635 -354214502 -229134976 942552942 335918055 531938822 -600450428 -768147997 -622832307 729114427 -700831861 645538629 504811844 -870448…
Output: 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 998259270 …

Example 2:

Input: 2530 1753 14584763 906949388 975910047 9046736 -626753145 -360616270 -389443613 462545216 285375377 -737344371 916005338 -845355270 -165550412 -265381176 541425402 -626987166 -828412703 769290104 -359784685 -627507372 -776377363 -954486880 -194571756 595775016 -224274071 -967349451 -533483744 128438721 -962689827 760915120 -558911947 -498557344 160215475 -112196508 631440855 -218649562 -495607480 457160883 -50696858 -612047679 -991966308 873282490 542442026 687404858 -91642307 148544222 197228894 -1726490 -22201805 120407481 336461869 439179864 776999174 576930631 6585165 990479443 -869098566 104620054 -127639230 -919131878 514120792 881453701 927440436 500776087 256286919 900392962 448075292 -365621374 -431213457 736698590 -450972269 -512432428 543387993 -396482525 485811654 287256955 337…
Output: 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 999614079 …

Example 3:

Input: 3870 2542 352006765 -409646801 679147962 994543741 393318119 7398394 756731274 886774575 730805155 867910248 -334883681 171988232 -15129439 -369568156 -554231762 528980673 111468655 368953333 -200981139 -380457935 910309038 441328721 -128671364 -94364757 931120523 -909578038 -20671841 -908541654 742894973 60214357 -629697003 597693476 275843610 76880544 -531035096 487921491 448252096 769385808 -742860018 -689025744 -570871707 354101091 -44772186 136776851 -220636948 -700740201 198816769 799930704 -437465914 79607507 755428851 817102133 977714032 -837268341 838001443 -377311711 -206919960 -647514658 -15943071 -262493337 225954620 -655696743 -954643658 966362560 -679640665 -175933403 746820291 728658269 -972954567 556957699 -935649703 -498877612 -98645515 621769771 962693250 -151707098 -9353…
Output: 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 999143923 …

Constraints:

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

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