CT63687

Ojas's Verdant ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the copper works of Verdigris as Ojas unrolls the day's manifest of ledgers. The tally will decide the next shipment. 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: 396 682767417 448974996 228078685 521183453 -375025013 215092374 385787949 106503599 -849764611 771426290 -958923371 -434939346 831743228 -87757149 82750166 829180734 595979736 -106151657 -284852304 367840592 823210684 -107989997 -856467374 -248212280 436675036 -63324471 -874154611 -751331315 -247696296 -532486605 -175422288 -927015702 -564845832 -138469354 521711512 -604441508 569640565 341451777 -906994395 644384810 -643397148 313161245 -406444949 401915171 -72672847 980498563 835073363 737483875 927855885 858961819 450198259 -909328687 -324291456 -116044579 -521403410 -743350378 -42880969 417512458 -485155789 -742533405 174273183 491753581 -491581843 -297328601 -858714387 -31326049 -305683609 -730311442 910701919 -620224870 -686680408 142968393 -2714914 610514617 255808982 -869176131 -8…
Output: 682767417 448974996 448974996 448974996 448974996 228078685 385787949 228078685 228078685 228078685 228078685 215092374 228078685 215092374 215092374 215092374 228078685 215092374 215092374 215092374 228078685 215092374 215092374 106503599 215092374 106503599 106503599 82750166 82750166 -63324471 -63324471 -87757149 -87757149 -106151657 -87757149 -106151657 -87757149 -87757149 -87757149 -87757149 -87757149 -87757149 -87757149 -87757149 -72672847 -72672847 -63324471 -63324471 82750166 82750166 106503599 82750166 82750166 -63324471 -63324471 -72672847 -63324471 -63324471 -63324471 -72672847 -63324471 -63324471 -63324471 -72672847 -72672847 -72672847 -72672847 -87757149 -72672847 -87757149 -87757149 -87757149 -72672847 -72672847 -63324471 -72672847 -72672847 -72672847 -63324471 -63324471 -428…

Example 2:

Input: 1761 -997330455 -230680967 -605040164 612222040 -437609173 -775967996 750515443 966042047 -453854679 367624516 -336052702 -679872425 376704837 462938479 312014666 657480465 311985611 858991029 -864015509 110003615 329833276 -553359083 -173964671 265354474 408338272 -336083590 954559411 -337978718 -466536391 -198563985 -358631164 242154435 -22624794 -52284897 428522105 -451979951 -230094232 -612190998 -412254212 -961726020 477541156 -593510816 -89559356 5814919 -192799266 868040287 113940322 717269964 -941862338 85485710 -622599305 -308374304 100071734 -733686517 -65035471 578119765 913721952 -253596233 331876918 -273493996 -758141160 -254074396 -922669298 -380367013 -422663797 583355360 -225505995 -235816844 -444186650 -668665886 -53451403 -140423638 910540242 -460953398 395609207 -7105210…
Output: -997330455 -997330455 -605040164 -605040164 -437609173 -605040164 -437609173 -437609173 -437609173 -437609173 -336052702 -437609173 -336052702 -336052702 -230680967 -230680967 311985611 311985611 311985611 110003615 311985611 110003615 110003615 110003615 265354474 110003615 265354474 110003615 110003615 -173964671 -173964671 -173964671 -22624794 -52284897 -22624794 -52284897 -52284897 -173964671 -173964671 -198563985 -173964671 -198563985 -173964671 -173964671 -173964671 -173964671 -89559356 -89559356 -89559356 -89559356 -89559356 -173964671 -89559356 -173964671 -89559356 -89559356 -65035471 -89559356 -65035471 -89559356 -89559356 -173964671 -173964671 -192799266 -192799266 -192799266 -192799266 -198563985 -198563985 -225505995 -198563985 -198563985 -192799266 -198563985 -192799266 -19856…

Example 3:

Input: 118 208214756 570215369 840103437 -459634963 420643273 -723784434 628871285 371202726 -148508460 -765187224 995972481 566277133 96293500 127709317 -116654292 -481275237 325376821 40911754 7011305 620363866 318240123 -967950878 -189388257 326687244 -78282735 427589771 -682400015 889520474 -385355546 840440470 738038859 70146369 445016950 585090935 -963580895 -440737877 -148729310 811913095 224745907 -239958657 -153502066 -439252347 -722537055 -583863929 -900006771 -289779683 -217426280 809918079 692890343 -342713607 242285211 504739676 352367209 253004274 -902637330 490028436 -317905691 -396350758 811531011 824174637 953815489 -870666782 -612336826 189722884 -855550366 -91299518 374744186 -159686081 -572455879 17420608 168560569 -912321985 -381718074 401938448 487546677 -900904748 -30953317…
Output: 208214756 208214756 570215369 208214756 420643273 208214756 420643273 371202726 371202726 208214756 371202726 371202726 371202726 208214756 208214756 127709317 208214756 127709317 127709317 127709317 208214756 127709317 127709317 127709317 127709317 127709317 127709317 127709317 127709317 127709317 208214756 127709317 208214756 208214756 208214756 127709317 127709317 127709317 208214756 127709317 127709317 96293500 96293500 70146369 70146369 40911754 40911754 40911754 70146369 40911754 70146369 70146369 96293500 96293500 96293500 96293500 96293500 70146369 96293500 96293500 127709317 96293500 96293500 96293500 96293500 70146369 96293500 70146369 70146369 40911754 70146369 40911754 40911754 40911754 70146369 40911754 40911754 40911754 40911754 17420608 17420608 7011305 7011305 -78282735 -78…

Constraints:

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

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