CT51576

Lila Counts the marks

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the wren hedges of Thimblewick with crates of marks, and Lila the bookkeeper 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: 1447 728 -296226933 -99944769 -28744237 364991681 -540102582 -433223894 111414341 -567686412 -695897877 -963409861 9716483 9868528 -380789519 327432719 -26237718 811031442 847878337 -364399012 256112319 394526957 -615071494 651753045 905636124 62891212 432311073 875575090 -666083900 443809473 -205399993 905090847 -500499772 518826520 -17641171 -268566704 -357797306 -73390968 -743192654 -13810282 -716797861 924970502 394604629 -850571135 -120870010 -205414931 -412578787 971273313 -85386341 -143070853 230470372 941299058 -142709306 855782013 469862105 -865810180 531985920 586248642 826419740 -604621929 -732874606 181088488 447667302 -737424919 206820236 401462015 -234482663 -120500109 360243471 822494048 116391770 193339175 -742521282 -713845333 234989082 -502679164 -686632134 948916837 6252…
Output: 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 992151173 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 993085429 …

Example 2:

Input: 2654 1444 786350909 -668132592 342639498 -92803930 474212311 931205086 -910753416 166056366 -762007878 812591407 -390260202 823661085 985812343 -170883150 -468323680 -701529509 434999709 -971253214 179144954 -171727596 -7379264 837265747 -126391424 -653957792 -774009573 -92721099 438318490 931112759 -242119488 238890169 -243815639 -598935915 -629823664 288231990 -274367282 -177836094 -63299213 610405111 -541765064 -776448512 -303825058 -606491925 973646253 442205095 992030741 -854229554 -799088985 917816908 767832917 -784311009 759008014 -901399637 537703015 167762582 -321208893 -573075612 -534569700 -462766515 -553163248 -680686385 -520402191 -350823662 41796494 -653100512 -242489 -83963745 683981753 222255597 332376348 -321892676 275255824 805812718 -376527992 281125912 892562062 7704624…
Output: 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 996096084 …

Example 3:

Input: 3648 86 333047028 -63520554 956230806 -921946513 -897650107 -858091679 821433586 159295591 -243533614 35363395 -42395806 632084718 -959818821 553683038 -675322342 -224356096 210256274 40762503 549870412 542056938 634354619 -372698468 -50491909 841064734 -781645196 -894987261 -162570491 -102714082 -238913090 -385670764 -625807479 -882711337 -54619598 45722433 -875515382 284441596 780214931 -99917030 -940995517 -398149188 -726258113 636090634 -382855276 -542085023 -690267282 -731823584 -547846929 -439952363 -100742569 -115254256 573084887 -241514521 -182748602 883784924 747567809 -890573038 982760870 996367579 -309694986 140638399 524234691 119696337 -123613842 345727857 17166962 143381632 -634849094 -883815362 899993516 -766702999 720390387 -70223630 -724444227 -671276577 -516920359 -173444…
Output: 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 996367579 899993516 899993516 899993516 899993516 899993516 899993516 899993516 899993516 899993516 899993516 899993516 894799797 894799797 894799797 894799797 894799797 894799797 894799797 894799797 894799797 988427021 988427021 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lila Counts the marks - MEDIUM Coding Problem | CodeTikki