CT53249

Weaver's ledgers Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the garden city of Petalbrook, someone must restore an old family record. This year the task falls to Weaver, armed only with the ledgers register. 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: 171 149 71306903 -542049214 100755130 651207964 -427046896 100667939 -944970967 741951503 -278219183 857250601 601260680 913690323 165560498 -830308489 -8630439 -467435387 387580872 -428981125 -746347905 970054918 -337396954 512871930 -804617505 319781961 832327612 983150877 -684581879 -469592609 -65311960 125876242 -750461722 -38282286 -292313921 -40079218 684331720 159443835 -201357213 171753794 911767185 356619835 819179023 -675073838 383532589 -405907412 -46131366 573639034 535640684 196172500 -999861083 -751819370 136215188 662664198 -698075464 -340008248 616196675 704698948 -511891962 -433230793 446090412 836270953 519630321 926530416 903262028 -716996326 888049553 -154119881 86115164 -695783462 -666108662 475178408 -63757074 501262845 578047018 -945599881 474918424 698995598 -591705…
Output: 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877 983150877

Example 2:

Input: 2563 2371 -255766344 -312456101 873442644 135399502 -913257453 -85160259 -302331104 -457716611 233517992 533950989 737246292 -626890967 573668211 -73124234 -282822747 971186494 576386458 652992227 487889117 866396766 -339873379 -381127383 -893891739 -209152636 19215849 732800717 -21404816 -946666856 680781581 -642640795 934531794 154295396 -367826875 392960146 -626735080 766790756 921493412 379521599 -507172188 -904495774 -586533649 -365509905 -415526809 211524163 89641830 -442069153 -474941667 -162854277 958813584 -164608136 287615233 -218524330 395952266 524424091 -962644243 262946007 130069218 599539504 -299487435 97875744 -215399343 -357528092 -465111825 -483070986 913252599 234626891 38052732 774007337 -575490692 -843990123 -436528622 798978381 233172324 -432444094 639006888 313760012…
Output: 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 998746454 …

Example 3:

Input: 1357 18 -105727809 -891580055 -560194714 -135105621 -510617083 -806879732 849121291 -581472907 862557303 197751042 -710581519 954295168 100392752 -554956226 47443125 -860143032 -296869664 -314406355 -351345041 618746476 565313564 -378177109 789890178 303797126 -861704630 -493348978 561817538 -86812488 57637151 787805092 103841129 498956063 138135266 -955282467 320476731 28514462 534170294 -453594463 -811972017 612032465 18272423 2126588 -675713684 -418153451 -171942684 464634641 -992356219 -21866484 -589023391 730947815 928237527 -39975659 -366612005 -716724914 851566326 -58110036 434409695 -525257568 -920234579 -160680567 20040451 -415629180 -415871226 658683400 550682132 299969039 460011995 245637337 -985062583 707459759 893279385 -848887234 116291006 938805225 -971990380 -152512319 7763…
Output: 954295168 954295168 954295168 954295168 954295168 954295168 954295168 954295168 954295168 954295168 954295168 954295168 789890178 789890178 789890178 789890178 789890178 789890178 789890178 789890178 789890178 789890178 789890178 787805092 787805092 787805092 787805092 787805092 787805092 787805092 612032465 612032465 730947815 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 928237527 851566326 851566326 893279385 893279385 893279385 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 938805225 920672491 920672491 920672491 920672491 920672491 920672491 …

Constraints:

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

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