CT40545

Rowena and the Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the moonlit lagoon of Selene close for winter, Rowena must finish the beacons ledger - one figure at a time. 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: 67 53 -858736269 30497425 27026525 -978673437 856129414 963669623 789122247 -336770083 100683139 322810700 987821044 132281698 -436264590 -182942911 561718019 437822114 -174815944 929766464 -722946199 -563791522 943936745 -525297597 -177198057 868374870 350541420 -156839712 422251179 -290535372 763483953 -188864208 317136380 -957116235 -539575305 735454606 -25468914 -307477574 -475099453 -635790126 563126911 318182261 303531161 74138171 552492567 433887549 -485565402 682881058 -739124134 -46144036 -832207561 -334452730 -32025076 -195737866 -578146338 135019292 -793914572 -317022031 245016563 714961204 -49080165 -523079458 -122861558 -716668029 -560057569 -940665136 -824831804 -779346934 313379019
Output: 987821044 987821044 987821044 987821044 987821044 987821044 987821044 987821044 987821044 987821044 987821044 943936745 943936745 943936745 943936745

Example 2:

Input: 2517 233 960318006 -971368396 496366996 -386727991 580653286 -640198907 523735507 314094493 236131264 855549518 -50388736 366635494 698761673 218111238 -695569521 -861867721 139009685 911197996 -152858426 347590579 138708297 -246610717 410698711 801206523 -415176415 563281900 975198933 -918878354 -957061319 -269369182 236928696 -280823409 496542837 -389725393 824875557 805223980 722189773 -989607342 -964625300 -368085076 -304874163 -504812377 -329903231 -239685361 -744649136 -341970874 402749143 -402714459 -485445233 -219907867 -200805004 958647265 819054843 -305139742 -854412186 849698009 231137988 416450243 83618319 -145131658 -888846472 -489015392 648439311 -262291325 -18872795 254785943 437415407 294526648 625084492 784384218 -139901740 397098333 -368990919 374487657 75133887 268470523…
Output: 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 975198933 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 999354157 …

Example 3:

Input: 1950 1466 724458351 -996647959 682410078 -255470228 953497292 -835995616 127110877 -526588580 342678519 975517605 46084892 -146188219 523788916 230794172 -968344511 -974843163 -205869385 119676724 644948013 -41135778 278013374 -577092431 -534761916 -599598245 758074469 459785750 753318995 -811258743 255453558 869516454 -110084096 -982972996 490305734 896932783 -646395819 799998045 -745301862 616880839 468542495 694427001 794214951 329587091 536921106 -585558282 617126282 705546312 74095827 -281751141 510246483 -183160215 834253008 711406585 -679201303 631215937 -673690314 -221340263 -906948486 959795197 -268274964 556547028 -270207927 -94959968 869155651 465514622 460931438 -826869890 888576206 -163779113 -74623923 34256111 396672715 221522004 -281560655 447565919 -894495960 -926055286 -34…
Output: 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 998779908 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.