CT60156

Dorian Counts the registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Every season at the silver mines of Lodebarrow, someone must fulfill a tricky customer order. This year the task falls to Dorian, armed only with the registers register. 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: 1903 206189955 309632933 -93998789 530504115 -406737010 178805081 -213851094 474415576 282153659 -695639780 -416350494 73606970 -836548223 -993916262 351653904 220480377 554119559 -722015846 901276375 431691849 729152136 -4102055 11795714 -192869548 -928505429 196208374 -211616149 740130192 307932737 -282184322 576689873 79280099 837637679 223663905 901768222 192319678 865365558 -59555773 308069821 -757868666 510706944 -854986452 305194084 817743279 -71719163 609730948 846448749 -545044650 -460352850 -324654076 54116148 -853451473 -490794917 -552214417 659415123 -136750522 637200628 35287374 -306245022 -777283621 716423776 -110856724 574152728 137133615 404918889 238352591 354107640 318344996 266973414 -114887068 -76687964 662629262 289977415 770071026 -417451807 560993884 368831049 -52288…
Output: 206189955 206189955 206189955 206189955 206189955 178805081 178805081 178805081 206189955 178805081 178805081 73606970 73606970 -93998789 73606970 73606970 178805081 73606970 178805081 178805081 206189955 178805081 178805081 73606970 73606970 73606970 73606970 73606970 178805081 73606970 178805081 79280099 178805081 178805081 196208374 192319678 196208374 192319678 196208374 192319678 196208374 192319678 196208374 196208374 196208374 196208374 206189955 196208374 196208374 192319678 192319678 178805081 178805081 79280099 178805081 79280099 178805081 79280099 79280099 73606970 79280099 73606970 79280099 79280099 137133615 137133615 178805081 178805081 192319678 178805081 178805081 178805081 192319678 192319678 192319678 192319678 196208374 192319678 192319678 192319678 196208374 192319678 1…

Example 2:

Input: 2726 513289830 514071100 -956413705 -24665650 -892146219 887125232 -547485502 -268772311 395808814 -819299519 -40911609 -878326411 734844858 884257639 220526910 -594621605 232495980 942601282 844284131 909236861 850095575 -628776481 -658966592 694717425 -570844304 502539111 -427955092 177600990 245101968 -776629099 727168017 -465590606 -322140600 -683846352 189558414 659013081 -149947842 -731406396 964639165 -736038262 329921957 535891844 -816945914 -99504624 -926704907 700495569 -833015221 -724775457 887410067 -957011722 619393404 154008888 -442105911 185507617 300444763 -417016606 -189034369 -504849639 -510873448 -246972759 -913475526 245815283 793455760 -327894049 -198289465 -257153290 524142168 -329074302 690501229 -879558335 925677255 357231773 705565355 -19929845 984881382 -802003815…
Output: 513289830 513289830 513289830 -24665650 -24665650 -24665650 -24665650 -268772311 -24665650 -268772311 -40911609 -268772311 -40911609 -40911609 -24665650 -40911609 -24665650 -24665650 220526910 220526910 232495980 220526910 220526910 220526910 220526910 220526910 220526910 177600990 220526910 177600990 220526910 177600990 177600990 -24665650 177600990 177600990 177600990 -24665650 177600990 -24665650 177600990 177600990 177600990 -24665650 -24665650 -24665650 -24665650 -40911609 -24665650 -40911609 -24665650 -24665650 -24665650 -24665650 154008888 -24665650 -24665650 -40911609 -40911609 -99504624 -99504624 -99504624 -40911609 -99504624 -99504624 -149947842 -99504624 -149947842 -99504624 -149947842 -99504624 -99504624 -40911609 -40911609 -24665650 -40911609 -40911609 -99504624 -99504624 -995…

Example 3:

Input: 378 119851730 300594293 572021864 -247947085 -129104136 -409810172 -707002665 707180560 -997071492 767955421 563503411 -438426756 589168655 533813151 885452633 21811317 397434761 2147286 -144073189 543897809 702718877 779952778 380926118 -289268861 -738957442 -603253895 -158486876 -225775425 837433080 341026837 682184259 -201360079 -836739593 403703186 25475469 644143292 357778267 526325364 846935512 853201799 982005054 -373568162 200317628 -659620729 485598678 -626404780 538280317 -842482270 894518069 -703719299 279562833 907599558 521613660 777125809 602226006 513461663 756597866 -126981331 -455998527 18950866 434660145 -606981094 922483506 704278374 -946579861 113617450 -873660048 904566984 1273848 489841012 127371546 831044175 689761933 561589913 224214319 915989479 -577484519 42533547…
Output: 119851730 119851730 300594293 119851730 119851730 -129104136 -129104136 -129104136 -129104136 -129104136 119851730 -129104136 119851730 119851730 300594293 119851730 300594293 119851730 119851730 119851730 300594293 300594293 380926118 300594293 300594293 119851730 119851730 21811317 119851730 119851730 300594293 119851730 119851730 119851730 119851730 119851730 300594293 300594293 341026837 341026837 357778267 341026837 341026837 300594293 341026837 300594293 341026837 300594293 341026837 300594293 300594293 300594293 341026837 341026837 357778267 357778267 380926118 357778267 357778267 341026837 357778267 341026837 357778267 357778267 357778267 341026837 341026837 341026837 341026837 341026837 341026837 341026837 357778267 357778267 357778267 357778267 357778267 357778267 357778267 35777…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.