CT50107

The ledgers at Cindercrag

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the ember mines of Cindercrag, Vera studies rows of ledgers entries. One clean number will settle the guild's oldest argument. 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: 1531 448 410471772 640428730 -808734064 -63873333 389701162 -714640197 -936036409 -25202318 702433966 337691641 225085130 -297136034 -374114628 118512319 358028951 861682588 -534542742 -144788692 615813479 435776343 502108181 -413710753 461706230 -53698536 911852909 -962715805 507988477 -942529887 998896184 273738007 418598258 335907580 -22885472 -726645527 -565207769 -228218062 -57451481 -280927770 -574731353 303743419 702621785 262363746 -319009475 -288780037 -297113769 303338768 532016652 541308745 904925418 639452308 -234119103 610612325 -548362040 -920887284 -114088979 -267915553 534131703 740649523 202087976 302275488 352292789 615223118 -444509801 -382834320 -453682557 198855821 474149293 874203550 -813603946 -25522008 985982595 476024260 -675147064 985455452 -879066537 -473451261 -…
Output: 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 999448062 …

Example 2:

Input: 3292 311 -376172383 804574573 654674085 -123409388 96071294 -319882182 -211007944 -638148361 -392647041 -517624355 -572565980 63495180 -927929364 152257812 482684338 -242396369 77620143 -910006847 306556545 728207168 -214579442 -976387517 -684110411 112064511 112837215 710121895 794396138 -986430629 -706783788 237973946 -413784861 109248932 -43063991 -279534519 795269058 824586651 902248927 -870641393 286389953 406927884 -284639879 783888819 349814128 -117002 -438362700 -429231314 466609103 -830928540 -285987913 -713413890 646002524 -878394730 -698925655 659279075 376036316 -884945822 39376653 821981559 974191901 -503283487 462167742 -881393273 -549446661 -258916337 -370786951 -451442494 520446377 30903130 -736082373 -579862607 451698522 -604783415 -759456230 167813325 826074316 -356483065…
Output: 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 980096967 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 988887316 …

Example 3:

Input: 3218 2716 940426502 -790421065 320130910 887853046 508239063 -813231056 -867750634 -593276799 -434317197 679426922 820848530 -21805966 -549965055 -92325857 -157374582 -673401336 326586820 -352691868 -259856926 -98843821 -30161783 415815612 -781712394 489489741 -587494527 -95856881 12936604 -989353518 -13104387 -485088186 -384181789 -953991211 -642988897 949548152 953406308 -955684221 -839025773 28030414 986196233 127749514 -492734648 -765329877 836419528 -705939789 -818917758 407309826 -399864410 -274425085 802042398 -501612546 515680175 -749106895 189384655 -923632542 -324601902 293071625 573868405 554757030 -597788687 629845389 705628755 -102161476 -648397469 439111775 -809998604 246608169 362176024 -889209534 -39709990 -645207488 816713077 93669083 -175903018 841695136 45053800 -5555706…
Output: 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 999256465 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The ledgers at Cindercrag - MEDIUM Coding Problem | CodeTikki