CT40680

Steward and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Steward runs the greenhouse at the mountain city of Highreach. Today the books show a list of ledgers, and the numbers must be worked out before sundown. 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: 39 7 241216509 281147372 -696429403 -965551634 -458038208 -277474525 -866140624 202985450 896798122 740953293 865823667 133585497 -451434255 628780982 -613008853 425645395 602942652 866341150 -162955217 -741402461 -660423401 513055511 628683124 989159319 -91184728 -242808128 -287688935 -757125695 -93060475 -54291713 770503069 -833755944 -915994846 918365060 -543118065 -67107122 589612892 136816794 998611986
Output: 281147372 281147372 896798122 896798122 896798122 896798122 896798122 896798122 896798122 865823667 865823667 866341150 866341150 866341150 866341150 866341150 866341150 989159319 989159319 989159319 989159319 989159319 989159319 989159319 770503069 770503069 770503069 918365060 918365060 918365060 918365060 918365060 998611986

Example 2:

Input: 811 772 -601991587 -449860893 -348802784 400953276 343724314 517554205 -201114166 340070224 314663497 406157392 249589479 -627795944 -523030002 648811781 102347689 286048186 -207165143 -162151082 -999553218 901172125 -917344537 743629877 560278107 955230648 -773199822 -32955990 851305417 -234999874 658697656 327650262 856765191 850008152 -727816948 -738237715 -915595572 943581650 -355378876 -305024126 -682193279 -504781434 -153524380 494703428 335292894 -38375372 572008744 709407251 12582868 -950614356 582753007 455189485 -866681215 547127394 331481418 -661021519 741419734 689468154 -325727289 529423412 719555036 -259930134 369170173 66176397 -134370238 365857051 558299708 755360041 636425841 -678288623 -176356930 -519598304 83923853 -740634035 -235552245 583375403 566908051 84900318 12615…
Output: 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943 999322943

Example 3:

Input: 951 230 36639062 127819667 366483668 706021631 728911528 611042338 -603593420 803737665 37686783 -372145121 65054352 450033190 -680932220 -4541560 250909891 442716081 -621957266 266967512 148372147 684376445 348862093 385239152 506175010 -744097516 49902838 181506889 -948247333 68863517 461080627 685222087 -465190039 -60480628 960299747 45228097 275638001 665747818 -287771375 18665837 619478927 -621340242 974619005 -930839785 -833414107 -634274831 413430586 152622599 -954203476 635249478 -136739174 413525617 -443632038 350977461 -446911329 -446418897 661154143 975043864 338812382 811154156 375951354 467675035 884186757 -664391114 843573109 -73746468 304951965 -322033439 -364558953 319951030 -561963136 -520416545 688305240 122373230 -706299928 -180569374 -363120597 -345054999 -707419627 -93…
Output: 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 986586102 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 993309625 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Steward and the Peak per Window - MEDIUM Coding Problem | CodeTikki