CT61590

The Peak per Window of Grapehollow

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Chetan inherited the kitchen at the terraced vines of Grapehollow along with its curious bookkeeping system for signals. Time to make sense of it. 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: 2123 626 434601666 -326708225 -687877234 617973690 -719110355 642067469 205994791 84523027 -240310729 -844329959 81439420 -563882616 634179751 869260371 -354816 -141274540 -605817446 -637066429 965571076 561177156 -143039603 46929199 124109417 635159257 -51606273 -923882542 33691987 -771917267 -940324327 -448552158 414079052 284858004 -145929417 671495992 -620801216 572721824 -609176111 361798919 -589590172 805389209 261668125 363479101 67895199 -658435132 -465794118 -127147415 -955127293 -565049224 -43314419 -744160421 -983585146 -953381916 628245950 -578167688 734882758 243834681 934982127 379420411 318502379 459387922 -759449442 -818244516 -745423405 23293056 -208348031 877201292 -506297190 349855824 -62593559 -446471148 301420765 -801682177 -165101393 -227332659 -122516166 -124995840 -…
Output: 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 995633492 …

Example 2:

Input: 957 777 947821738 -404733495 -422540816 86094890 -140194722 -37759051 298012920 -172489733 -642615451 -574956581 979862540 -234290907 947785160 -867912628 196035454 60996315 935876110 -704900656 431281518 -480627136 -355786003 613546231 428714362 517123294 480070845 942710397 -620459961 220545907 -412921198 -794571212 789382696 135850310 603870446 -70849370 809886601 239230752 -889929211 60536302 -574346872 -601357823 -610026034 146584675 -216879053 -418271710 842867251 670254396 279629950 -554485967 -743414689 -260017571 -460244952 -887520447 921729938 103498245 -912657400 986885578 -294107321 -505827050 541440834 169244398 -256378352 -133361936 -160430318 496585586 -482421810 284209041 761956738 -638640693 -218705122 -142213555 -537773098 -323810227 873590363 810839587 -668318140 3532624…
Output: 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 994081420 …

Example 3:

Input: 1426 1329 773105954 -29075928 -124878559 700417098 746779938 577013703 -768301770 -315079332 -90595163 473017924 627514629 946440566 -911526565 806089251 802418998 -290436559 -205135464 314105744 360320551 434990353 654072672 35503012 -534936631 -454340524 -10753863 -553921372 -331339643 618714071 119667939 95451456 117758914 230150081 -468808010 -147566149 311589994 568220515 886961130 531965654 993535169 51241115 -187070656 -526626036 387704050 -568849845 -13594870 -578533464 -921559522 876213889 -173042300 -407005428 -346749463 83301584 -167133463 669255279 928531616 7884469 -891334705 -554762133 -424783840 -803470268 -519393851 496814612 552801596 -60035529 890834689 -218942962 981976848 -529909175 321996154 -315376529 -125565407 -176614361 -311197367 905670422 214608420 521530306 5277…
Output: 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 999304363 …

Constraints:

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

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