CT61767

The Crosswater Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Rowena found an old ledger of ledgers in the granary attic at the ferry landing of Crosswater. 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: 1112 155 -600076592 215361353 756901885 -522595133 343403916 219854787 -9099347 600317871 -475988796 835389857 -853107474 964325913 456083046 974354291 -14202706 607514565 221321056 -145526762 514780532 715099272 261215200 58948889 -446648466 516181380 -412846649 269530630 193458808 -42729565 -452442251 647107657 586692631 -5991563 854299526 619212016 -791707565 -396976347 665362853 408293354 876684397 573039598 371599209 570014786 77751891 -980243559 -169152374 758860288 708419074 -98224479 -314053202 411284534 -45482248 340648076 -43840938 187681645 -632412493 -207459533 -770708214 -720868196 -455811646 290939626 -307749374 591615366 808013376 120731481 -63561326 -813388775 389057551 923253255 465436378 57330112 568672681 -750708456 398928399 -913580404 -404147018 305064799 975370920 -23…
Output: 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 999528931 …

Example 2:

Input: 2701 73 -36275178 -917068145 535265164 758755968 -585813851 534169234 885623910 77463756 -261935294 -153387303 188487713 116308370 526601019 -900696024 714523846 913420191 756573523 419278284 -354277437 -421421499 -582793789 -50496747 -177609227 47803090 65073645 -524129410 530649809 13371107 61077342 -369406613 167171907 -707944847 -328867635 257643504 -486433959 93651363 112347508 -907297260 876408151 891015271 432388136 -289247392 -65896817 552193183 591110934 897506041 -896254371 872307530 -555816574 -931561073 815692033 694798730 -299571284 282699538 797169769 -544472079 -386380748 -84190827 918556170 995240771 -566267689 816582098 828084510 -47922117 849561524 -871808268 -217387416 987674319 34583553 -969019595 923816597 -544296438 335122476 -723542663 -715842273 527439130 -579642200…
Output: 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 995240771 987674319 987674319 987674319 987674319 987674319 987674319 987674319 987674319 934012943 934012943 934012943 978172611 978172611 978172611 978172611 978172611 978172611 978172611 978172611 978172611 …

Example 3:

Input: 253 19 211239714 -698641210 946431802 447702671 -229695142 -3977344 385526935 158900399 -75012463 -363938548 98111334 -50882044 -199580718 20278416 873923775 353048211 589047449 -78003871 767410991 125664298 -339304507 215284092 -407753158 -208278063 280250014 123365954 349079106 272192501 -283667396 -773089342 -529587635 -657919217 -975329786 -487934465 -254869800 -945499775 -99924694 675240328 831009969 231404129 -517098226 991427489 -126604205 927427230 -508813347 388788179 -755248684 -351181269 -360276312 543156926 -659145034 211952264 149485424 845038709 -396433477 617065661 -168082958 -624060007 153266015 176173212 -981898983 -141315647 -430193739 -991946034 360074865 731712440 547235061 -171548244 784089577 -540681371 440009300 -113450763 176127948 -669483450 243843139 780428359 -85…
Output: 946431802 946431802 946431802 873923775 873923775 873923775 873923775 873923775 873923775 873923775 873923775 873923775 873923775 873923775 873923775 767410991 767410991 767410991 767410991 675240328 831009969 831009969 831009969 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 991427489 927427230 927427230 845038709 845038709 845038709 845038709 845038709 845038709 845038709 845038709 845038709 845038709 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 784089577 780428359 780428359 780428359 780428359 780428359 780428359 799273404 799273404 799273404 799273404 799273404 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Crosswater Peak per Window - MEDIUM Coding Problem | CodeTikki