CT58886

Sara and the Indigo registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the northern keep of Frostgate pays by the answer, and Sara intends to earn it. First: the full register of registers. 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: 2049 741554441 -494482181 637997274 -329795026 209960407 -263647795 995049833 300358957 -252587531 -290542872 -2586176 -878801002 778178024 703164971 -466305657 -932788509 -56209088 758063322 -427917428 130491652 386731604 934755775 -567207664 -88083951 863250707 -145013538 26680780 -43388626 -72673664 -126643495 -247528051 410277337 -451021021 -808183583 108650090 621331074 -555857363 167524768 -635041 427318980 -274627126 203453740 -820277215 -117963298 598859392 239275735 -724677934 -98960331 342730080 -168277137 170502336 -92307648 -922642898 850441609 -250265654 295508092 203052971 92393070 875633538 -480132633 -114096568 159134361 -450330257 593927288 -511684959 551639277 413094242 -623435347 -31556336 914638900 355522923 270629230 -543284181 443319296 -490248613 11772718 -362874563 …
Output: 741554441 -494482181 637997274 -329795026 209960407 -263647795 209960407 209960407 209960407 -252587531 -2586176 -252587531 -2586176 -2586176 -2586176 -252587531 -56209088 -56209088 -56209088 -56209088 -2586176 -2586176 -2586176 -56209088 -2586176 -56209088 -2586176 -43388626 -43388626 -56209088 -56209088 -56209088 -56209088 -72673664 -56209088 -56209088 -56209088 -56209088 -43388626 -43388626 -43388626 -43388626 -43388626 -56209088 -43388626 -43388626 -43388626 -56209088 -43388626 -56209088 -43388626 -56209088 -56209088 -56209088 -56209088 -56209088 -43388626 -43388626 -2586176 -43388626 -43388626 -43388626 -43388626 -43388626 -43388626 -43388626 -2586176 -43388626 -31556336 -31556336 -2586176 -2586176 -2586176 -2586176 -2586176 -2586176 -2586176 -31556336 -2586176 -2586176 -635041 -25861…

Example 2:

Input: 2037 -25834586 -640347919 -189391392 -274154143 -951948448 -963608822 422776862 165320460 981970443 -990041001 -327100490 254314316 824563670 -577981879 -782249399 321714169 -101788760 -792111065 195224781 940490862 250398635 -910668924 -259087953 759806236 -444328486 438082785 900209202 619972727 -392965304 635822699 -905815230 93962061 -632073523 514961024 -700074663 -218974051 -450180849 -463749128 350547421 -135621138 -938978504 773746591 -488372268 829896562 -671634914 491494614 910190577 291528824 -41621446 -19887851 174641963 -468860507 -368665411 385046813 -883895580 -718850047 -62382692 527557560 107989282 949611154 631520213 711397237 926583277 -582686202 -798258979 219111477 -218930616 437735167 -582361227 -48628271 421097110 -571543450 -570530373 813948424 431157516 929852199 -…
Output: -25834586 -640347919 -189391392 -274154143 -274154143 -640347919 -274154143 -274154143 -189391392 -274154143 -274154143 -274154143 -189391392 -274154143 -274154143 -274154143 -189391392 -274154143 -189391392 -189391392 -101788760 -189391392 -189391392 -189391392 -189391392 -189391392 -101788760 -101788760 -101788760 -101788760 -101788760 -101788760 -101788760 -101788760 -101788760 -189391392 -189391392 -218974051 -189391392 -189391392 -189391392 -189391392 -189391392 -189391392 -189391392 -189391392 -135621138 -135621138 -101788760 -101788760 -41621446 -101788760 -101788760 -101788760 -101788760 -135621138 -101788760 -101788760 -62382692 -62382692 -41621446 -41621446 -25834586 -41621446 -41621446 -41621446 -41621446 -41621446 -41621446 -48628271 -41621446 -48628271 -48628271 -48628271 -416…

Example 3:

Input: 2003 -466864415 -783537048 -119141723 172787387 -955132790 -557458613 -921310728 -790543125 864540900 159832350 169528886 669056535 427337060 704454044 768214396 497361035 -598518140 758353028 938041103 430146975 -298498062 912789436 577662176 756677047 328260397 -936781170 605953094 973100858 504303493 -495400686 198498621 -93302236 13774278 696093770 491312672 918131151 -748267379 496867548 -486233322 969608647 -329452851 875815433 -543946224 262606577 -618618275 -998727757 -187171718 45766271 -59088080 475837556 -454136346 -645418101 124861440 958680988 -220521831 486708557 374430435 564291411 516101209 532668217 469039519 -761833096 75796 -649126968 205659834 -503875924 612200880 -438783210 971493323 33082243 446870366 57168590 -704199010 -841705867 -130818158 243252579 156131583 -8130…
Output: -466864415 -783537048 -466864415 -466864415 -466864415 -557458613 -557458613 -783537048 -557458613 -557458613 -466864415 -466864415 -119141723 -119141723 159832350 159832350 159832350 159832350 169528886 169528886 169528886 169528886 172787387 172787387 328260397 172787387 328260397 328260397 427337060 328260397 328260397 198498621 198498621 198498621 328260397 328260397 328260397 328260397 328260397 328260397 328260397 328260397 328260397 262606577 262606577 198498621 198498621 172787387 172787387 172787387 172787387 169528886 169528886 169528886 169528886 169528886 172787387 172787387 198498621 198498621 262606577 198498621 198498621 172787387 198498621 172787387 198498621 172787387 198498621 172787387 198498621 172787387 172787387 169528886 169528886 169528886 169528886 159832350 169528…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sara and the Indigo registers - MEDIUM Coding Problem | CodeTikki