CT39273

Jace and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the marble forum of Argentium. Jace spreads the ledgers records across the table and picks up a sharp pencil. 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: 233 186 -250496163 -78833116 486482656 569866584 49833305 -379807469 922433888 -16727742 570381626 426481071 -964657588 390665694 -316110237 626248189 -24495641 281374216 -207924403 -267336160 -33441467 -231792471 907557449 -661110351 -99672518 -902643762 -220084867 314622116 -99506916 792205054 899112352 355404334 -815361147 293957203 -306958181 865740962 779857393 -46436742 -88171177 -724358089 399635078 589057964 -363288721 -70593053 -853912396 466213175 226643867 -445391707 668780146 -277516881 -624944140 411761010 167951174 -342205113 -757105859 -651491506 505793573 857452529 -715782208 -516657947 85543895 365844957 434006857 69740644 872327797 547866024 904284552 138072863 792440458 58589622 829307516 -508443277 171390067 -890845318 -41535062 595344300 986871984 758664959 -96533295 -…
Output: 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984 986871984

Example 2:

Input: 2547 2250 800436177 629017922 622555411 -421515188 -793982574 666687313 158941356 333378666 35735810 -285529587 -772496968 872260943 -686163641 116952134 97975434 -521072877 -634420348 -630903969 308104647 468985707 533630107 842893993 726739068 114129755 777433624 32326915 881325797 874605601 670012026 47193322 446162829 651999701 300913672 -833075813 76381944 67330389 -749197438 723314084 801864234 -270917805 970925165 142729563 606973928 -759110080 -877603887 -276338444 -5845149 207078651 74362638 -314666112 831014609 73183955 393135145 253108830 -335769739 -92406354 562218615 -47814594 773903492 -874496225 540586316 10790422 415925986 -752528409 -285253092 48032947 203858189 -254320722 22509392 -599759464 218626664 -789195056 906860552 -227602483 -242083888 -837514541 -836098288 767089…
Output: 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 998897109 …

Example 3:

Input: 3877 1730 534462019 -912651505 -81411919 400561843 172842713 -932364488 780499258 831765410 -718029340 -291078213 -135952684 -753866866 177290081 -548109660 -30097207 -839408186 -368310022 445683890 -702661219 -505515940 -590422198 878495998 -165615133 236606195 279324675 477740619 427499366 -421635364 -118300162 -228165437 -384546030 -743663438 -810629021 -572558809 -667378142 362829083 -570690883 -513721760 286868330 -937038162 996918329 298117194 -632953098 109291476 138632253 496493163 441236452 -258361333 -597959337 -257768003 -329208177 -744782135 111916176 -575253126 88800634 479415890 731538480 710501113 -802183045 -561461068 584533500 63737301 -85203553 549495748 -852435144 -337595526 -889296561 -34477002 214428564 987959826 696091442 -345280677 -365650833 362901872 499977627 1305…
Output: 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 999504414 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Jace and the Peak per Window - MEDIUM Coding Problem | CodeTikki