CT41580

Tinker and the K-th So Far

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the quartz ridge of Glimmerfell, Tinker the factor keeps careful count of the beacons. Tally the donation drive, every figure matters. Task: As values arrive one by one, after each arrival print the k-th largest seen so far, or -1 while fewer than k values exist. Input format: First line: n and k. Second line: n integers. Output format: Print n answers space-separated. Constraints: 1 <= k <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 971 86 -366609037 -276691426 -850972570 893453305 493194229 790224568 768854727 -638755339 -160643976 -99798872 -897425999 376102325 -204560107 104481629 -351848385 -268843504 910533397 496623438 -815004315 844022244 -150433089 -318595578 164945307 708277174 401523093 -598983637 -629068982 -963227883 252931560 -120614659 -24496632 308014872 48822953 376841823 -139813357 215048588 -235429436 -953301374 284785208 -851182065 -879719819 288958993 24699804 -852180858 -298058094 -304130506 -120403704 -267348374 -991930627 -814003829 -20941876 -602916401 -232135925 -20234527 181737643 -618520379 -291233163 -46502132 -965662443 943930962 12971408 -598438940 -486206044 -219254926 845361169 -636827490 -200058899 581781848 -690174165 645219070 -155124658 417847267 659472270 183690893 -306444962 23968…
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -991930627 -965662443 -963227883 -953301374 -897425999 -879719819 -852180858 -851182065 -850972570 -815004315 -814003829 -809152640 -740452181 -722569730 -690174165 -638755339 -636827490 -629068982 -627272911 -618520379 -618520379 -605825194 -602916401 -602916401 -598983637 -598438940 -557222040 -555354718 -555316322 -496625678 -496625678 -486206044 -452786386 -437195834 -415184366 -415184366 -415184366 -411009452 -411009452 -377381997 -366609037 -351848385 -351848385 -318595578 -306444962 -304130506 -298058094 -291233163 -276691426 -27669…

Example 2:

Input: 717 23 -126834754 61107175 466597446 -704317343 218539218 -954815590 472599154 -273704013 854572459 -787520864 -587121553 -983186232 432552957 745780456 668060192 283665629 195156057 825080474 35704749 -168563902 651652092 699606946 -928526324 -933366392 -160489160 -42834135 990779850 -780066508 -290275835 -506081074 -427135435 -630813214 375380225 352584014 -481593712 661800346 365703702 -602848339 53704492 -573497225 722218034 802138531 141549790 -322452937 -269590641 -495364720 821523710 466114468 -229425238 384734462 455991153 825104047 -954033145 -65794402 199147699 -888375951 -534355648 -908787777 -392734938 332593076 22349513 372254146 701999376 -128177748 -80107002 -267377499 -651051182 -306550006 -966567368 323447260 -222318064 -341427306 -212227666 796572167 -183655879 596175126 …
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -983186232 -954815590 -933366392 -928526324 -787520864 -780066508 -704317343 -587121553 -506081074 -506081074 -427135435 -290275835 -290275835 -273704013 -168563902 -168563902 -160489160 -160489160 -126834754 -42834135 35704749 35704749 35704749 35704749 53704492 61107175 61107175 141549790 195156057 218539218 218539218 218539218 218539218 218539218 218539218 218539218 218539218 283665629 283665629 332593076 352584014 352584014 352584014 352584014 352584014 352584014 352584014 352584014 352584014 352584014 352584014 365703702 365703702 372254146 375380225 375380225 375380225 375380225 375380225 375380225 375380225 375380225 375380225 375390174 384734462 384734462 384734462 384734462 384734462 384734462 384734462 384734462 38…

Example 3:

Input: 3786 3728 -342663756 162447772 -26132216 224915416 -326873725 952641374 -805968195 -836533588 813340644 766130560 -79067023 -433943901 845792624 -496586279 887640601 -785811640 -164010582 -752952873 -392844306 -775700123 -303483036 900130085 237139121 406405330 -371707874 943237041 91359812 279861777 194072505 58516439 266018138 777080310 -394534778 513876583 -76108022 -908283246 -552134549 -935140094 888801680 635526313 492826192 -938837521 -578476519 854465062 -350777073 424645607 -960613906 420827793 675911023 884011422 571432155 -800620607 -334914295 737952131 242213969 955228686 -762462498 542388558 942225833 27917939 -325156798 -886452925 -954669464 -578454562 -247698737 -160128170 910091250 -687537425 -42140769 -505353729 795246250 803474081 -731761757 -853787302 -34482694 152276768…
Output: -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tinker and the K-th So Far - MEDIUM Coding Problem | CodeTikki