CT58782

The Frosted marks of Chandler

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The paymaster Chandler has been asked to settle the inheritance fairly. On the desk lies a long table of marks 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: 3756 2467 346009083 148439191 -417058509 -660677762 816693836 -913989612 -3980994 -380326988 193835222 907166825 103728197 132314586 713095606 608114319 438409291 658522983 -509906061 903226903 -337563716 126733179 751475901 -138973433 115620309 -753359983 425059894 207148440 262644196 -522700857 413708226 -87665527 -250024235 263404526 58364764 902823232 180550623 531289141 -38767495 205847831 -820321232 127329307 333842995 125964651 14977764 -494294988 -377287 -966416313 -54793554 5230528 -440356201 715043292 351799059 572375255 728345926 586708426 -568523149 -693549753 103292201 -73913188 -685851694 -227210965 -330742311 -715005750 826260382 -724221173 -216700668 232593437 -606954521 -24149643 131933729 117647970 876507785 986893214 -704825726 297734574 -492097569 -540908170 -236917956 …
Output: 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 999120532 …

Example 2:

Input: 1163 881 827854233 799568824 -961650047 690784796 -976951203 -594217967 853626570 -816923792 36877471 678359759 391403379 -253384598 391232038 -897050447 -283564305 998807106 -544343382 -32477818 212746568 -632403614 -205405836 -360605391 -455901348 -385832387 456410611 141427942 -152567236 764555746 -152245401 793615898 37893933 -833249041 -347197472 -924425291 822017922 882064548 -436250498 -307360667 -259138423 853003361 36471285 -205656420 743539367 -756677170 361002632 -467852426 -676495783 380805669 200737246 -572896554 -566913106 -55039430 -489785781 -405726004 -78295867 184524921 299009529 -634853699 348072143 -401933525 555102059 231481573 960313224 -670122996 -380516272 982986962 519379788 -116310781 100019648 -238114686 814977374 824912015 584404452 520081891 -653001639 -9611912…
Output: 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 999391349 …

Example 3:

Input: 3379 1386 -638696616 -899547182 436069295 -308218604 199171433 -907379651 -438074308 -194629290 925613367 795725030 896214834 676583789 408777692 -463642689 924526206 -973566734 42434291 -549269061 117759873 754824240 241166903 -459970974 153067285 -634198762 623973026 359135159 145703726 806052634 272766651 783756530 -667454387 709009032 -390093345 -676469728 319064795 172219827 451280566 -169300090 281360785 411841753 -79667302 926554666 -261275359 -857754604 -209894766 -580082374 -290131728 334272921 309174916 988393281 221200888 568884372 -542434508 -317308047 252788416 725797454 124611048 -58668098 183485773 35159705 -871509638 -884330342 -287220445 829278658 -945326976 993392940 -601856786 -458281083 125505141 892834874 -508042836 -253770191 358321596 -469190094 -377488511 -899186439…
Output: 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 999318232 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Frosted marks of Chandler - MEDIUM Coding Problem | CodeTikki