CT52707

Chavi's Peak per Window Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the fjord village of Deepwater, Chavi records each ledgers 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: 437 421 -701807746 -638516775 -308323328 307901235 -294823312 -285879110 -554647056 -566783462 961451571 -222902967 423491526 953248561 670980181 -318545621 -46722811 587637478 -62975802 295281392 -457111000 785095029 -410631204 92295161 852458151 -894573978 -624199164 681194602 -15509944 195455409 187091152 -60543179 -882063821 555643887 -862307152 438403991 73191523 -609382047 912377638 -245805966 903755861 -684680814 -335317905 268492521 520593180 753708611 902355283 -669312099 644446150 -444452789 -125972867 -566100017 -195572974 335386182 -147102783 920539028 461761071 459623861 342936785 683477909 775047283 -670537736 -926741896 -978712936 321425873 -601959955 -854651411 392947690 -128527983 208201458 -152987695 420911067 -640154410 -80268544 -883288054 -131770400 -887382579 -3706302…
Output: 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896 992535896

Example 2:

Input: 3835 412 828162898 116726080 -103164848 745363786 -337375383 38741949 340475495 773299272 12826197 667227255 -355321914 -732507393 -353940503 373861250 -362957700 -139586063 -444346790 -541822883 524527982 -144078696 626487855 -35131546 168015777 -612599326 -914604793 -668348819 878949130 -835254038 -167886363 -436566470 692626975 179251827 -75556418 752868485 -808953580 -945568745 85271465 -497320873 -867827406 -543970705 267743108 746695810 224869911 834780591 325935938 -721369180 935029451 617733099 -764789124 72581170 -654457408 -582652279 476755540 -979573385 -989057208 -658597126 -643811117 -986687253 794564958 -363180616 664614400 -466214400 437604073 398266790 649825613 344422474 417776918 -806037373 -998239704 -125454227 -83085850 168010382 715737930 979943301 -943855717 284265148…
Output: 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 996423392 999459033 999459033 999459033 999459033 999459033 999459033 …

Example 3:

Input: 826 243 -317110743 -494467527 529816263 -893664483 685185440 452696548 -593634043 -455142172 -65186587 6144770 -168241673 329673997 615402203 447149350 494487839 761989373 18138052 986443751 -867814755 229256884 -160132279 -420365904 -979687825 -396148868 381293104 772491835 -168948625 846647747 -952467818 675505910 699844930 570578777 210140237 443919348 -739114220 -916673694 940821434 674124362 628994089 64573905 950961106 776848584 -776690198 -459411765 907875201 -900514916 -978164052 -618285728 598003900 63186565 487923085 406586171 -491580297 694992294 386686097 911024197 541933910 211890281 -161915889 -280676761 576579585 636436392 -868175438 -825400373 -426491938 -364668690 177343481 -471406762 395810377 385604463 809347506 628131181 -313819806 -776383018 125136593 654623545 3597641…
Output: 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 986443751 961608450 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 975327108 …

Constraints:

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

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