CT44706

Painted registers Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the port of Emberfall with crates of registers, and Weaver the tallyman must account for every last one. 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: 196 183 877698521 -819232055 430198800 -875101106 -369775689 -185607081 -103241957 -476182262 -165318498 752375772 -735803563 -548654652 -726070908 27508326 909746691 875040826 696935789 -256507100 -676101897 -383866133 914348596 -936992015 825956550 664734452 -835433205 -818895972 -477372937 81959238 -321772410 411231491 -293968875 408847934 912878186 -960092394 935758466 -676190426 738450547 -645762013 664522459 -106148872 -446043862 873320719 -820349957 480865712 -424333678 -387262496 -719567502 -914818063 232343119 -777456179 -671632175 -915710726 -611302102 730728712 -844432438 -215156133 16115953 519924956 287993507 -314664155 -274022223 -458717000 538816336 -594041875 -808741988 904167694 976503364 -878598245 -162057991 375849349 -375003477 -70969821 -788173130 -690054078 128641821 …
Output: 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364 976503364

Example 2:

Input: 2492 923 589638572 -916360983 114068258 -749264686 792976423 -676855495 -251158402 -64358774 -627274581 959668542 -622480059 -264570309 -722688548 879881146 -860918386 610011806 -726439751 908861719 -980872438 365779968 -992776030 432514839 -993218324 -661591634 991330677 804019084 359120327 -909280610 270187016 -346087138 -83364586 140949729 -443615878 902823874 595289218 -57924516 -97717029 -158215603 902668468 -990410448 -591954594 389626081 -980531451 443750972 646293955 213934794 -864311420 -431295508 -864846450 -151292239 -809555783 139947098 721846941 -865704608 826481523 -865291050 -295708763 457152463 303260522 -927836525 -838475690 -763142699 -81904477 -636804306 -338157200 -759410638 247403521 -809495569 -838893747 -831402125 79036680 102627681 803812042 -649666942 825386983 415…
Output: 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 999927634 …

Example 3:

Input: 2391 1828 -659006560 676401864 -577110026 -780800062 993514058 398100362 757430681 -494064472 930698669 692498351 -337537667 296924322 810853849 -627106721 638658030 -583648689 510374181 360930922 704609613 123980306 769483034 827038505 -702460820 -432157670 93566041 -151215780 784124729 80993822 -497829426 306260117 -456000349 -116502071 -266062732 439266070 180928628 190812504 232587758 -242158909 203813626 123862549 -999849966 -235167246 -211461080 -704614857 904317600 376059318 134910647 476699805 -798642049 797205047 311628555 343582121 719662687 -829992962 404228677 -925256946 847567915 -11781076 35496191 -976194655 -686716585 -761876765 -731388241 -588557373 -524141202 772322678 478027174 965544045 -828242165 -445703551 -715400384 -760498382 -759643551 813391610 -523877318 652442824…
Output: 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 999702425 …

Constraints:

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

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