CT53179

Neel's Ledger of signals

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the seal rocks of Barking Cove opens only for a perfect tally of signals. Neel means to find out. 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: 1742 1505 712452407 686767525 794559563 -59218654 962241260 -132815125 -624703404 560001262 -48888937 -291105997 212974278 -670479538 651881589 400511024 -965707509 -488048571 -509853967 -529725963 -76588668 564528346 -109469208 736024095 -762496165 801928249 999700723 -463624746 -732049599 422261837 928672525 -102419667 168070609 -435210493 -784275209 856275919 349961790 857715058 -356779605 539683704 240921582 -340798850 -928718232 -979324391 467759679 -259944148 -191575366 -520375033 556837698 591211247 25980724 482706685 511684565 -463513768 -676757392 -705357280 421067832 729327256 556305871 508560567 88112534 885358479 -585925232 185466922 325146504 58072273 -813106352 -603933381 -552414631 -613349706 865584135 -218808946 397082861 -809733579 715469434 -309715683 923080881 200604826 …
Output: 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999700723 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 999065656 …

Example 2:

Input: 3337 3315 101320212 -22741331 -122184584 -594011568 -149233267 -925504797 111379597 -892182710 842711254 871465611 -685585204 -77539000 669138872 -301202786 -895450002 586817065 476385628 -213639939 -837072390 931391912 907075857 101099990 -821549667 448584561 784401417 -524549137 -718528671 166814902 41513974 -680786328 -688014477 -585619189 428505802 336530777 994301803 663612425 259712395 166315898 926011134 -656682304 919520854 -328357626 -522186103 -644700438 -623949548 -132739030 608884339 -999413680 -153034993 -120080268 318869509 -277070997 851510621 360880154 -722012993 486680334 -634843421 -800743316 374670864 -864220209 304688696 -322644757 -918888609 991458388 -430913378 -873210064 982325897 724245789 -504752433 291346016 507404616 -951788322 -393636651 -411067964 -153784622 28…
Output: 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622 999903622

Example 3:

Input: 2162 2013 -452575806 476369244 -124251981 -871337915 -649453876 -102187244 610453492 584736700 816656983 662756664 -304534405 246871543 -417145632 304994297 230827909 330780034 -950306908 343466208 -524005777 -658008283 -869590284 -311141684 -901740355 -554353051 -711027953 955433298 -202230473 889782697 484218014 -910298994 -921234509 745296230 -621097152 -615935391 -407963348 60055556 -718323103 502600334 -10197057 318323820 919134341 -687645418 -555138683 -412242093 -623232037 -261523692 481745730 -77706740 -382189167 -808926891 -551438816 -447575687 53144925 560604445 -450999990 667109293 -677932427 -446217199 338567795 856034193 442357148 -375682473 -271869312 358922244 329214748 -420932917 399570466 -494775694 639179605 166206914 817276096 -827595308 -28501167 432091567 -96068087 -83…
Output: 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 999190054 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Neel's Ledger of signals - MEDIUM Coding Problem | CodeTikki