CT55268

Last marks of Sailor

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sailor found an old ledger of marks in the fish market attic at the snowberry thicket of Winterholt. The margin notes pose a precise question. 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: 261 186 487282787 974552679 -85822500 -655165688 -250247765 -614907028 232341537 -600182942 -568976269 -268531127 -259689763 -795855577 845981238 -836331543 -224268183 -409480295 -393036579 -76642000 -34478998 136345065 -982722557 -989989963 732871636 -959832564 -512121907 243409368 -297742778 -971228907 660084836 -296933080 -687628566 -237980136 -85230256 -564551366 695819741 -34635110 888928635 954766182 939169479 -236700924 981841675 -537961647 -968392533 -511061370 713271869 -228039717 657065004 -729950122 142257564 251203865 -159674081 968693164 -491953221 561014420 212387698 -446522473 -516209418 28983382 -719914236 604385761 -663812385 -116171611 415528268 -523836280 901993170 564791538 905805725 85895152 959600656 198013040 -320171927 881222020 340410508 792689290 -456609252 400321…
Output: 981841675 981841675 981841675 981841675 981841675 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923 989159923

Example 2:

Input: 621 470 417798531 -408568391 429682843 335731859 107523022 -361260516 249272324 418703279 -261112258 -90144347 -415432727 -559143291 -839080287 -597921761 954241949 -766340171 -505567165 81144888 573995089 -60690202 -806799314 -231244280 304165859 -592242776 -860311919 977768530 613050167 994356394 440325528 -624001658 620665172 558664407 -555266935 -431239025 378787619 732742661 215838001 -80886660 245354267 -400824515 -432022156 -182901053 614963040 764232760 75449089 -894337277 -324825909 -456663117 781597770 99567951 -650040105 23322134 143100857 562604104 -78846561 994110248 -835061491 -85524582 866727024 418375096 -323523230 -529472881 -995926525 172810893 -166070088 155037869 -306015972 826669681 269270519 -109257510 53488160 -371616194 -576997292 933939289 -696763536 -463008427 -49…
Output: 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 999418979 …

Example 3:

Input: 1793 1519 -728897126 -55099998 464353357 -269638218 -953432143 200669606 526618635 -641001970 -322982426 -879121497 175266976 -349986945 -562203835 -86205776 -416077484 81649412 -761746251 929509522 -22913450 -474340641 -341262124 -308603080 -639184744 553737430 403201132 32049301 -746571882 -328923757 -637766021 32484279 -721141129 -784953039 717462855 312995183 -148116898 -8491201 424584920 663750025 -393535029 855782050 -89450491 905920362 53449973 644849252 -730246552 -913910929 -676360275 -907540305 -974127736 -654247187 -701524377 83777639 675343772 336994872 961223343 -420175156 19807147 -126729927 -167519531 704013766 921413093 -103616102 582290477 843590689 649684983 -64572338 597412685 -455382497 208361773 562457007 -97877453 -221001310 -634489472 -247362706 -225298981 -974607160…
Output: 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 999571401 …

Constraints:

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

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