CT41489

The Firewatch Peak per Window

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Theo runs the tannery at the caldera rim of Firewatch. 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: 1255 452 750169834 363787356 -16491077 -529652518 376933720 -891562269 111815119 -358892090 -38120960 380204 -57162318 -816457242 632341475 925571716 447619770 -146775695 65130577 -149666262 563137653 400836318 -402242038 641128793 577229379 687500770 880421035 -232440677 -485258330 148940598 -423504612 161054946 -948937269 801939161 -358979086 -246161484 -947123795 197192713 -632669853 -323154217 -527378023 -752419588 -152559550 581397485 922340353 562582562 -802212203 233342946 435370156 -269781328 -289908094 615329800 573430638 889110858 -534194461 302938296 335289900 713436053 -263485966 -211598184 398109846 435603619 59331583 -108808247 523705301 -511496789 -898380229 -604435945 920630100 -547000385 883063800 57317019 734057886 -730135403 763439278 994141594 -417691432 -106357575 -710…
Output: 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 996733849 …

Example 2:

Input: 3955 2421 454391920 140110085 992702582 -734369474 615807702 -345766707 686879436 -506538642 -686808963 175263373 847816816 905735968 442142830 362753182 550925049 590876559 302613448 490661748 -10145533 75043712 -348996775 -505689994 -205810347 -459156337 477869187 -371743545 707481569 -750296194 733988859 475004446 749127634 -578013747 -32865726 -796390787 -243553544 193010579 -908701765 744875436 -216101900 -321811713 786813363 826343071 -274538968 -877281563 -485327343 -718090363 -971076773 465241536 316682268 842192890 369830825 -899567370 616035970 -286154814 687745209 -871324123 -291263436 707707960 562852434 475900606 -74055580 447700464 -638147015 -577523008 -485390299 479841157 -743006079 -840976772 -230019045 353938909 -45520696 575561787 826491952 -134521782 138921976 821313038…
Output: 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 999806998 …

Example 3:

Input: 379 350 217350993 -187200785 233813414 877535077 -547286097 -238067606 272557685 -796725866 -96516258 37255350 249244496 -28962770 952787100 -745627943 -70366584 -727924094 705606905 -128593447 -595451796 902093550 -681202325 -900440731 -632904348 903960415 692218282 222320054 -977615375 173090836 111873383 771569445 924422243 -103599660 -368707175 460566715 480545181 -756559131 -944037012 -270797966 -151272384 787754716 335033933 -773618132 345336920 -343700759 846061412 337442186 -81713660 996253461 -354912244 270081392 243340249 30546440 -199476565 -932893029 423322386 239778842 -655655111 -743807920 -922529234 -285545712 850524646 -246948751 -878258517 458605936 594705805 368940818 -467602814 607363761 -129908078 -342538881 798705742 -401392751 -903132522 -119613628 313444003 -39052058…
Output: 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461 996253461

Constraints:

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

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