CT38802

The Peak per Window of Stonehallow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the granite steps of Stonehallow; Quill weighs the day's ledgers manifests and starts the calculations. 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: 429 363 635504913 812609908 -151619011 -652687547 -344872160 -340933859 -573019032 -656344284 77971030 156015865 879188255 -709173672 -924534072 319248241 925907306 907446447 -705186222 693815732 777685942 864694986 -102536025 133026 -59428767 461285415 -465606236 -168299760 -990661629 -50077053 28910457 -154084500 -210556038 686403076 -275701191 -377504023 -921534915 -540674579 712519426 -716901826 722104615 -481093789 -665868694 515975843 172127746 -603566762 -48943042 518978133 744112173 397116211 -81230548 -283623218 673851069 -470754382 -951144269 -935297192 -870915760 -783880779 -69985173 136701372 -836572015 958692923 676632508 81121960 242761266 664039373 431354370 710607392 -325126074 -239786340 528623805 302211740 -909691342 113889694 707743285 50859611 579794979 -490116389 -9988…
Output: 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965 995592965

Example 2:

Input: 2110 157 416270108 -872515311 550163825 -352150370 138561283 430081594 138700450 105247476 -597279507 855032352 -739094746 -705714444 -751155467 -282696155 867381920 -595706445 125247624 -452231751 621382071 -424881794 931334206 -574228843 -315092997 343363361 615729493 -166671134 -626904299 86693773 -749910388 -506372823 683450320 751310352 412946913 652624185 -706595557 -3500676 307173928 695153346 323876474 -995270243 8176516 -174423931 561605349 -328726669 -527980477 -317628464 571429897 217305027 816466342 -350164902 -370351041 705112959 219715695 380491307 55045289 122166408 429633476 -49198340 -685040875 818393559 -572744206 -595546821 369931725 636425683 753903468 746184900 235017876 565385585 -873104244 205991433 -151049019 332202152 -254208442 368237547 -166072658 673485328 -1497…
Output: 984752680 984752680 984752680 984752680 984752680 984752680 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 988402541 995863065 …

Example 3:

Input: 1700 795 636237207 964348448 -231265527 -92010318 711460136 -944056547 28421353 648374882 -460876348 -827691648 969847735 642462418 529800653 152649880 518950859 -21577814 -690978535 162178489 -791736712 221297248 97600406 -630805517 -628663120 419454749 834492893 -181991926 498897286 658166499 692240473 -71299848 330087556 -878619036 -113070218 144947877 -865319885 680020330 -382836970 32172776 -5224892 142463568 -34780175 47833128 129044068 346210987 -81454915 -754935462 -159658571 232155541 -185225297 -563171130 444951068 620486453 33389487 -608754306 797553507 71036145 59784248 -180600497 -326021804 834074490 -140419192 442466866 -561392843 333823190 -786019563 673207359 -118158668 -424948293 -611660072 -166906209 -979789809 40384447 -117061041 272737577 -224727938 -938656672 -24714243…
Output: 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 994647631 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Peak per Window of Stonehallow - MEDIUM Coding Problem | CodeTikki