CT36778

Sarla's Garnet Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The store warden Sarla has been asked to approve the repair estimates. On the desk lies a long table of ledgers readings. 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: 2850 731 983196775 267495842 -850918597 -688872098 -720081088 -615573731 -956922534 948447395 173571591 292282298 -706716333 -915859857 750334092 647939157 -482262576 347020302 468687341 -242267441 103221291 -341393858 767875391 -45199975 -269920932 -213193714 -705136842 -388257677 -693798760 287574073 -882950452 -653116444 -807979059 913197099 -452548304 -645279287 -450077927 -716506170 836674790 359229121 -218209828 783780585 433211338 983041750 452397662 -718339185 -891635545 623019633 696711269 960219219 205311120 127958700 989072532 962230159 604212474 406797856 -26499612 427498147 506001329 137474906 -370290504 176901032 453520835 -814608944 -695353025 629256866 406046446 -47288236 224195595 416605740 -251558856 -426966568 655619031 461907392 -719735203 -561113224 646327544 -33191032…
Output: 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 999237810 …

Example 2:

Input: 1827 1213 -508962025 -897338661 -661093165 -676794064 712436046 336007641 -791034934 -305273122 -885512852 690001605 405950433 595384948 -897128906 -752569631 -803666239 -497346447 697809980 -555513656 626422896 754574696 -411549278 -346490789 72333638 41925301 422717736 -740737906 160113863 132228776 460405312 24133080 949222337 -273918385 647099631 -747468014 911858066 -194675146 311194157 190507916 586431627 -550571636 -334563424 -223180453 92391487 -729369763 9453253 870416348 582886971 -700182869 -360546231 95529641 -905934143 897823998 284358511 601065835 940218035 324872400 274633877 -295372810 322404800 393935166 -102957678 973863471 -706991231 556972251 -956731446 -778656847 -35105888 -380817469 -909933495 -541360984 768257374 748142358 119090847 243767240 -464968937 -825312920 76…
Output: 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 999927734 …

Example 3:

Input: 1493 557 453365664 -99912915 -420126584 445260446 -604471317 626269193 -565143961 737114079 -448329212 730902600 413224780 684872399 500938415 456523269 800839918 -67942971 -106856566 588176311 -101541084 215953234 -245970183 -759369185 863578117 -644452976 156004966 467608641 50805032 -394003948 952723565 -912932774 54211020 273767820 -973926532 823223596 552346085 313773740 95964715 185952929 944909140 550472204 112002879 -923899730 632341623 210318720 -385334666 -205879150 151163136 807221457 -902700003 -372782723 -471181302 -124642117 -313322378 153968087 -866057048 837930729 -540158932 963036973 480598842 425217098 -560380111 833986463 -472809625 -62020876 -512801727 987348927 635942275 -805158267 138349347 724541134 -350170934 271899572 -504665750 -796792334 910031556 -40797309 -4511…
Output: 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 999752346 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sarla's Garnet Ledger - MEDIUM Coding Problem | CodeTikki