CT63600

Milo's ledgers Peak per Window

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the beacon hill of Lantern Tor, Milo records each ledgers in a worn leather ledger. The guild wants answers, not guesses. 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: 3462 3368 839779613 -362331462 -601319729 -17043658 918768257 734849805 513216495 879879443 -917680695 -131751279 -625918399 668826427 162200642 518635230 -692921518 -880547529 536980121 -959161884 331630443 928579795 150495045 -509564408 383609565 497446403 -740842812 483603899 -124227891 670827443 -81955374 -385852807 299785986 313876142 596050426 769782536 103200875 554569303 556338852 440446321 311268697 -848746257 914972011 429319057 23241190 -755388157 -672016767 -570772205 744948051 -938002717 -155293695 -301366535 831539337 266430592 -78513586 760856767 -412323047 -950866901 -664763579 873124299 -750570499 -39302976 -255383513 -454743526 143558762 -419508214 131185098 936471999 482315716 398490197 -347339222 119125740 -978923224 -304827947 -192977354 -346633649 10713209 664398162 2…
Output: 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 999147172 …

Example 2:

Input: 19 14 -399221566 977086141 -86408176 779646736 139517575 367209389 8797647 -567619504 -324450830 -726225755 -384436482 925390327 -268800845 718098255 604074991 159502264 -664830370 -711423947 213609707
Output: 977086141 977086141 925390327 925390327 925390327 925390327

Example 3:

Input: 420 326 -701354200 411159395 633978685 354310336 -314715411 769163781 431558974 -530585412 252935027 -506695762 657903477 -132063785 -740122009 -912444229 -231266449 -650349554 -842416092 47284211 -774954738 743114677 340403457 -188586505 348249468 -696061886 593054724 -765530877 957752866 338810010 769931514 42296720 219812076 -764759732 97802760 -192603708 350017169 227259818 341162540 568084653 -45842604 642909398 119831875 973746047 -206948011 -957184981 -28040787 -988334848 -92096774 -813140099 598826702 -76395376 830517979 323078859 -584283179 73973720 759945648 -505707971 -831549454 526084207 813699668 976150658 -427033295 -50664008 443407638 988989655 -118034775 141235629 9725439 996468892 -175932637 -340643750 502519971 -347366516 960416370 633001144 470460419 923955018 -171096106…
Output: 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 996468892 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 998397684 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Milo's ledgers Peak per Window - MEDIUM Coding Problem | CodeTikki