CT59648

Rosa's Ember marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the wheat plains of Amberfield opens only for a perfect tally of marks. Rosa 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: 2438 17 970236914 -290922896 -837220234 -812593197 226460517 884927535 -755617736 -284775987 -466004939 -636418893 323934172 409267148 477011804 829082212 404662928 -613155319 -694674996 -403887807 -862831015 -569759327 557750713 -922129605 -975357798 -399310220 385885231 374505185 -994416829 -382945936 -301609855 -740483469 -638708699 630417402 904232963 -772317129 -557558990 31279372 -775610155 268420487 -187053445 276291730 -250463787 -340622822 114036168 -645923876 -745667061 380439612 874504310 -701136346 42431402 -184289398 643886554 -485197861 929927210 740073361 -178164614 -893244739 -826747217 -847570436 -504777745 -721320270 -804335610 694283750 -291962665 631451612 741504233 541238922 235072329 359572760 -97888874 461157183 -213441389 818300758 253858835 998504359 424061363 -696…
Output: 970236914 884927535 884927535 884927535 884927535 884927535 829082212 829082212 829082212 829082212 829082212 829082212 829082212 829082212 557750713 630417402 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 904232963 874504310 874504310 874504310 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 929927210 741504233 741504233 818300758 818300758 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 998504359 868440449 868440449 868440449 868440449 868440449 868440449 …

Example 2:

Input: 3696 433 704529275 -821937989 -943033339 -988691608 -286711862 -21022623 -888020694 -970224424 -70051375 960760941 -258126102 366434950 695321599 -637028228 -495311471 813611219 838968795 451996404 153694844 116698002 604967063 -781786635 -660168681 221797474 -618301192 6370450 -549169623 -850220345 -275786317 242298225 -935123797 -842726381 -192624826 -984273527 -558036540 -555940302 -126320625 -201384440 681553465 558713044 486565831 367367833 935345056 -228607627 -290125403 -905577655 -960715460 154179084 -260613973 -269522788 784669975 -482093726 544381879 -552288093 -169243614 -193934454 676791575 436458937 -917378940 505361744 595834054 -119199031 570049165 730474799 424610898 711608644 834250901 -346227493 -928226278 187906651 -458576624 270909147 -959856773 792260539 230567924 2580…
Output: 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 991423339 …

Example 3:

Input: 2361 2246 881579545 -4411091 -550593366 -475055055 145246313 -755156128 -841938294 377731430 -140454054 614374589 321185345 -225766761 22673406 -926631328 589128639 -933445760 -563931913 653912364 -575605692 -514469735 -230879933 335025045 269758319 77999192 723072558 187668310 -589853194 -971806037 -844117851 -206591154 -173555187 975439374 420421044 470495809 930745551 -882197879 -438406155 -786642350 459329799 -932665877 -678844627 857656715 -556667298 150471146 112098558 -763445763 96603180 -83732055 780609154 -183716163 -526912256 -552555771 -327285179 986531475 -193844020 -979220529 337085333 -321460394 464824934 -815259328 -969768176 541876387 915502935 2236573 -497628283 -572228718 -474060178 -334758826 -935899139 295291672 -289103784 183944477 421291263 114979932 98218168 72578092…
Output: 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 999789284 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Rosa's Ember marks - MEDIUM Coding Problem | CodeTikki