CT49357

Elowen's Peak per Window Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Elowen the tallyman watches over the pearl fisheries of Nacre Bay's stores of ledgers. A careful computation stands between order and chaos. 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: 643 571 43745282 407382070 -151182835 121211053 -886668322 444432890 -105245339 486346868 549117632 -137754895 -566195825 -289352681 -625221701 141788542 879972481 -453088783 -534679454 628748684 -151120725 -218780427 521290051 706184590 -637084407 158589780 -780475547 -903121991 -878469716 272492104 267194666 466779038 -323926385 83464593 -483350482 78396298 -333786853 -475817123 771901676 173964260 682974700 497353546 -672400184 -519971845 -361742891 -72364643 -512926611 -447898861 -774401776 -555360848 -27021987 -712521084 -861910454 -643541791 409304060 207923285 867875556 -417048645 119036706 -80250306 256467374 729693858 886798682 308202651 -504055271 -491724671 -93046703 838896666 -267412461 -708360551 863477144 -959721742 811615191 685414819 64656603 -699141559 -136059531 854608275…
Output: 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 997569571 998451658 998451658 998451658 998451658 998451658 998451658 998451658 998451658 998451658 998451658 998451658 998451658

Example 2:

Input: 2943 833 866952541 -59918104 355556377 484393211 120549435 80881625 -884353143 -631003842 -800407282 -232104022 465627112 -97235611 -204379895 -260157405 184773150 -464215001 168123707 -894639997 782397859 -203422548 176959267 895892106 -810926418 -278309189 326284801 -330285335 -439512145 -94720864 62304228 -680318157 -764894289 -515128347 -879413446 164841480 -112233309 -322324575 -404974032 -348009169 983342066 -243162419 -653402980 -257889807 271303873 -56794977 -976227485 344064514 628434565 -480793259 891838918 38933900 -686601715 283786230 636624219 410527746 552567090 667622075 -306400348 949106981 225614957 671466423 -398720771 43601520 266005510 34635288 -478480111 260292951 320050066 722101817 156216724 -733080091 -563600057 -674427382 978524988 -592041759 -898935730 -345457709 …
Output: 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 999389873 …

Example 3:

Input: 228 1 558359060 485739896 -438456176 -151757995 -759315966 -744824326 885666103 370777809 557751796 -17215022 8471789 709428405 -434244170 -379134412 391122929 414305163 862212040 -549462888 927747285 938414394 25385835 -174270582 751935553 -64785837 434570141 371620305 -450719005 973841306 -998222146 766504603 881253308 -410658704 249575357 183866495 715193087 313579383 249585107 -570273684 -26686745 254384426 206508644 592463846 -266598118 986333409 753480426 415209654 -699380679 4118091 -232103965 -635994465 419061056 405630359 892437314 60843351 -887386297 234201651 963243922 -609126812 521540343 788465836 340200778 874745914 -901813461 881163264 359247624 494529736 287595823 551737249 -573465975 -361539097 -945628808 -106918568 287030414 488811660 174494398 651010038 233870001 9927590…
Output: 558359060 485739896 -438456176 -151757995 -759315966 -744824326 885666103 370777809 557751796 -17215022 8471789 709428405 -434244170 -379134412 391122929 414305163 862212040 -549462888 927747285 938414394 25385835 -174270582 751935553 -64785837 434570141 371620305 -450719005 973841306 -998222146 766504603 881253308 -410658704 249575357 183866495 715193087 313579383 249585107 -570273684 -26686745 254384426 206508644 592463846 -266598118 986333409 753480426 415209654 -699380679 4118091 -232103965 -635994465 419061056 405630359 892437314 60843351 -887386297 234201651 963243922 -609126812 521540343 788465836 340200778 874745914 -901813461 881163264 359247624 494529736 287595823 551737249 -573465975 -361539097 -945628808 -106918568 287030414 488811660 174494398 651010038 233870001 992759058 -87…

Constraints:

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

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