CT60538

Last marks of Anaya

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Anaya the clerk watches over the marble forum of Argentium's stores of marks. 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: 1888 99 266751967 339768391 502677842 -626975057 962256435 -116098407 232289232 -139631756 -683917422 -956450229 963706977 -475986916 850384132 164947821 314636772 426030145 459750428 703400929 544119179 -156701111 -567155428 -606699298 -885436474 -895284969 869392321 -519297385 -17505045 -784890100 -94165080 -387038593 -998012252 -301669355 346120735 -271564192 -837523752 -311099461 -306940724 802062294 79746125 425850878 -382771739 832779437 -35653662 331826201 968418461 611610695 -640394570 398880936 -366125251 -276729674 -394148727 279864271 710462055 86835223 531291359 203775896 976866693 -91613005 -632724098 126669262 120845697 -310366657 744083273 -339896715 -761174926 -895972955 -11913925 -573245516 -471185143 973501259 552960432 -648514594 -628667119 -346555649 -447219754 56570000…
Output: 976866693 976866693 976866693 976866693 976866693 976866693 976866693 976866693 976866693 976866693 976866693 976866693 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 989012738 …

Example 2:

Input: 3008 1289 705891084 637896535 -63642476 -354347526 -359264974 -661389427 199584678 492664811 -683098294 -121688145 -731699653 790188984 778495088 -836544871 381390166 494973206 329780839 -750411058 -503968729 798225833 -119592651 881127663 778271801 913551082 823163210 987775797 648100867 404548050 -700961754 -592010550 898328333 -741431066 913547865 -510745832 488319943 517501506 -780520762 -321668011 802014535 986435177 191952703 -585349880 -11746801 -267649682 -345723833 -848652316 -726543354 -339030616 -507200733 -927421459 4063786 -443867713 151794424 189704925 179447953 478307580 320991478 -716668587 -16856296 139132422 363988906 644365481 -364704452 607756471 -594219489 -858423832 -23835091 764416034 592036907 81017661 22261153 -782323416 -534365759 62448066 53278651 -581116578 8122…
Output: 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 998725321 …

Example 3:

Input: 2282 474 539349990 869569553 574247065 -455583711 -695138185 377893424 703167551 -896528141 838017812 185344167 287732812 -714510225 -429412629 743491635 -292915148 719985484 856601144 333327779 -291970558 -329420540 330356608 967484068 -158924051 978522255 -979129684 977975286 469116028 769433945 635282743 -340188020 970442638 695912697 -253399496 -114478521 -4141570 29147494 -258721997 -838329746 321112484 145258090 -597018571 -981252490 862508342 119026992 538614570 -344857827 -318815994 -130514319 -516505339 771211098 -438587404 -376810684 860758786 -206469239 -444521316 396728625 608322357 529638386 889480911 208789414 -207529815 -635510960 -758242415 917797766 -216590090 663716044 -138079208 303840404 -628889791 -856021750 -790293335 85323449 974877719 -822298629 926277497 -782313174…
Output: 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 997175327 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last marks of Anaya - MEDIUM Coding Problem | CodeTikki