CT38792

Zigzag beacons Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Mira the assayer watches over the thorn maze of Bramblecourt's stores of beacons. A careful computation stands between order and chaos. 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: 1235 808 962820644 485832476 -522291179 -945976621 690224522 -476080628 331038798 -147884293 63672948 -957037173 42827788 -7862455 780958208 -736727364 -743471213 -878186573 552104672 932260543 243949808 407724852 7700590 563410306 -63910020 881631818 -772235709 472088609 -889830189 -397771474 773525520 -43035548 75235638 -229670238 16717712 -451060964 -411760108 223994386 543992873 35733581 -857802670 -793405045 853311952 -705256244 573341229 -993132973 -23063497 -151868267 42265249 904366029 -548764922 177176143 106847785 -330698722 -625130836 -525724360 -941709379 637298922 -726695840 876358399 541026469 549363024 461273640 -623820977 48390966 23294675 -794749856 845045590 574456356 -63166023 -251776596 -198327072 973768272 20890309 180626491 -839870875 808803005 721563963 12164043 6711…
Output: 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 999892723 …

Example 2:

Input: 680 259 866471354 993650189 -307627423 578711037 -698676924 -146899374 -412668607 -475623385 222328578 -206294844 -521462160 292101112 -817295803 -662792591 -216049310 381801586 179302108 464649378 71771804 -122594519 -716496023 549181563 -901952654 -700296127 -267709958 -287103021 -123054077 760098098 -382559818 464021030 671709560 701130922 -650495599 141014127 933245037 520936778 192327517 -338890804 -923190867 -257237343 798967278 -504994074 848787825 352770829 506441804 32667582 821991305 -734812830 -505489456 -12828659 113298531 257646625 -131467768 -498307903 11897697 -71360128 544757157 -48125476 -289482446 36539401 -865627781 464570160 -483925500 -994538785 291244011 851974330 -637730576 -477549544 610589465 -378239278 24399350 196822056 147371860 -16935490 112820208 -534435113 28…
Output: 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 999192939 …

Example 3:

Input: 940 140 339523262 683675909 825072505 128401844 466452925 865126008 -150411261 304354678 606369691 -869924881 23609771 570783563 861708360 -707819877 942619710 111646853 -278055563 17145595 296318409 -614206867 -557128888 -936103166 -89817063 554983285 -526853700 -674419643 53881131 328309719 516238261 322081326 -933184259 717509101 -443418754 -595701722 -692034233 675880896 559662797 50679097 787425269 -890056449 920513690 -810595188 -289718985 -551803511 -409811032 768243220 -451791856 -929066837 -437191881 -141972390 -660105622 -196308665 568794356 404007848 -511852758 570569579 -270866614 678561523 896515500 -367814499 -272623650 -4783362 440087114 -879901280 -814732058 838926725 941711905 -430075309 375511467 351332326 279389112 -336876639 -910974343 -610604338 560967514 855767657 -73…
Output: 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 990332823 …

Constraints:

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

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