CT61637

The Middle So Far of the Woven beacons

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Deep in the moonlit lagoon of Selene, Pia studies rows of beacons entries. One clean number will settle the guild's oldest argument. Task: After each arrival, print the median of the stream so far — defined as the element at sorted position ceil(k/2) (1-based). Input format: First line: n. Second line: n integers. Output format: Print n medians space-separated. Constraints: 1 <= n <= 4000; -10^9 <= a[i] <= 10^9.

Example 1:

Input: 589 -167931529 378772613 -355117167 774413469 3466754 -70353548 749086764 667044937 675455509 452705144 75299079 -820051443 -485546569 45991745 -519707171 374492010 478815086 -705283918 993997717 666020106 537277585 -820812145 -769076238 964160537 -248568668 -233152216 -758768348 62392087 433943869 -85254442 182379193 799756681 -602234335 -235786161 -601340480 -421733824 -374013491 141368199 -347856959 -664637948 672638295 -141994712 -69168760 565976951 -585708759 -491715828 -452978799 -304445071 -559038590 323328080 -62651995 -841224730 -285666458 365747246 384935459 -758372153 912964759 -37479041 633752659 759529863 372301546 216455640 527810968 841458723 734416978 330984034 -590386631 965156129 14997912 914407199 -132136370 337020138 681099362 514266958 -918764715 836700713 -343939567 2…
Output: -167931529 -167931529 -167931529 -167931529 3466754 -70353548 3466754 3466754 378772613 378772613 378772613 75299079 75299079 45991745 45991745 45991745 75299079 45991745 75299079 75299079 374492010 75299079 75299079 75299079 75299079 45991745 45991745 45991745 62392087 45991745 62392087 62392087 62392087 45991745 45991745 3466754 3466754 3466754 3466754 -70353548 3466754 -70353548 -69168760 -69168760 -69168760 -70353548 -70353548 -85254442 -85254442 -85254442 -70353548 -85254442 -85254442 -85254442 -70353548 -85254442 -70353548 -70353548 -69168760 -69168760 -62651995 -62651995 -37479041 -37479041 3466754 3466754 3466754 3466754 14997912 14997912 14997912 14997912 45991745 45991745 45991745 45991745 45991745 45991745 45991745 14997912 14997912 14997912 14997912 3466754 14997912 14997912 45…

Example 2:

Input: 1916 898005692 -583082352 -938524607 656497085 850557379 773123970 -228686235 150076897 -788505449 509518182 -789719144 221363014 -415564544 -45198529 917840186 716787030 202909694 313621103 379611519 -845693233 16348461 -118498810 -972398961 374328114 -743588435 842711052 701653573 179366822 -275919655 -507914450 801396378 191525430 413999068 -242979208 -338917073 703572623 -530909071 384185387 75976364 -666670224 283283391 -994144425 -486624409 -458505889 -874607312 -162706046 -653755238 102975866 -264390243 -605469649 184243256 686570460 712464746 -582483670 301831334 26377887 48157736 -367632492 -431145083 496473490 667232702 -683884765 782110650 -703016465 -69538613 -289291719 456233037 424450355 201281156 -762119959 -557116400 640992575 214095963 -460894546 710359729 -307508813 47384…
Output: 898005692 -583082352 -583082352 -583082352 656497085 656497085 656497085 150076897 150076897 150076897 150076897 150076897 150076897 -45198529 150076897 150076897 202909694 202909694 221363014 202909694 202909694 150076897 150076897 150076897 150076897 150076897 202909694 179366822 179366822 150076897 179366822 179366822 191525430 179366822 179366822 179366822 179366822 179366822 179366822 150076897 179366822 150076897 150076897 75976364 75976364 16348461 16348461 16348461 16348461 -45198529 16348461 16348461 75976364 16348461 75976364 26377887 48157736 26377887 26377887 26377887 48157736 26377887 48157736 26377887 26377887 16348461 26377887 26377887 48157736 26377887 26377887 26377887 48157736 26377887 48157736 26377887 48157736 48157736 75976364 48157736 48157736 26377887 48157736 263778…

Example 3:

Input: 1518 396815919 -763455788 195737286 -792559514 -360762608 588061635 -477958947 894323124 271315200 56950632 40021215 552050740 -667338325 819106077 -324455372 142208753 -714775975 648236717 -405713251 293042240 313157049 -711347052 -587759807 692212864 -422701602 842966073 384874933 -256115576 148710868 521785002 533855096 -197426141 575776576 -40946607 -981798851 800635844 -427486741 163183154 860651759 879007899 -169441455 922224889 321097411 -995233924 293589857 799424154 864067542 668282782 -469064833 403757127 -167655485 -557075127 -116763548 -968847663 13439812 -617780995 -148288341 15304673 -308249925 4570052 818971503 808910407 -841530596 114773840 608135242 200891259 926371343 -469623922 -335621759 296271689 -27819319 -931035339 370379276 -711636976 828951585 416721338 773106943 6…
Output: 396815919 -763455788 195737286 -763455788 -360762608 -360762608 -360762608 -360762608 195737286 56950632 56950632 56950632 56950632 56950632 56950632 56950632 56950632 56950632 56950632 56950632 142208753 56950632 56950632 56950632 56950632 56950632 142208753 56950632 142208753 142208753 148710868 142208753 148710868 142208753 142208753 142208753 142208753 142208753 148710868 148710868 148710868 148710868 163183154 148710868 163183154 163183154 195737286 195737286 195737286 195737286 195737286 163183154 163183154 148710868 148710868 142208753 142208753 56950632 56950632 40021215 56950632 56950632 56950632 56950632 114773840 114773840 142208753 114773840 114773840 114773840 114773840 56950632 114773840 56950632 114773840 114773840 142208753 142208753 142208753 114773840 142208753 114773840 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Middle So Far of the Woven beacons - MEDIUM Coding Problem | CodeTikki