CT52356

Obsidian marks Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the frontier camp of Duskwood, Weaver the dispatch writer keeps careful count of the marks. Plan the festival budget, every figure matters. 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: 1148 832 -205144263 804386387 -327829465 152740698 12107266 -190779901 530401125 -21541143 924705617 -955977482 -122882669 -607020347 861330046 -126548932 -615661816 825785326 425650303 -285909148 -940762788 440471750 87126340 839804395 600885200 948620490 466904064 761278199 -93188716 -504537994 -294500510 464226209 -617612621 -253481908 198169625 -738193665 -593653995 -51119965 631233769 -612088112 657921068 214291844 -823258245 97614695 -174478814 -103566670 -942413340 -153329865 648684719 359538337 683690837 -463515728 105219723 80158674 569186535 467474970 -663993775 -187093648 861964210 -49119634 303754905 -215878324 40355304 -907587344 -535507020 -25058056 387576748 -219529665 -2288288 -798976240 819746353 -156751384 -643493961 -819488990 637687219 562888211 -667876505 -78864292 836…
Output: 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 999341915 …

Example 2:

Input: 15 10 -572604872 -587091650 969676610 -232808342 -759610929 585864378 479655213 769778336 158332012 -952960386 648044780 -102618995 220281254 -235070614 -212514957
Output: 969676610 969676610 969676610 769778336 769778336 769778336

Example 3:

Input: 2020 1224 -192735172 452132880 -675680356 -690795891 -378080130 -941146 -724407247 116623365 -502328625 -238102651 -742146602 -654289098 853537836 45230050 906447740 -313878379 726747940 -51206207 296485383 622300074 -127026684 434286307 958119312 -899223037 793987397 10994702 672269733 737467083 -737665899 582987893 385668731 -75414264 852615344 -940761071 -956520894 -92611920 -686098116 -834802236 -504382662 242951576 -282189903 987659722 -372321318 -107312667 791702275 404976287 -428812662 -174123289 107731580 -263278916 635894607 50753029 -593202152 346375295 353167439 -285261912 69538578 -924956576 457009237 -534879866 -399140351 452248115 -182988858 -950746195 408560831 -713042178 310371583 813046589 96681949 -783336489 655814420 -614644 -58512343 -898929056 881864427 278261104 -1662…
Output: 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 996613852 …

Constraints:

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

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