CT62972

Yara Counts the registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Yara inherited the loom house at the steppe camp of Horselord Plains along with its curious bookkeeping system for registers. Time to make sense of it. 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: 2550 453563574 -194677243 -495776982 217580419 -519361506 -752294307 -396175819 -610530258 -475118675 -436013657 927218151 25032007 325813167 -685267789 -565321068 -495344457 -427067147 -942140618 647492535 -771395308 -825298198 -35649245 -429221522 168265847 -238043524 411540612 -502817136 -766048013 345942685 989395488 636694963 -242026378 528900964 881235513 131711623 -771963267 540132312 -488822749 -216487193 -242669185 -338039665 712994798 569511052 253852603 -572314881 -236196828 -542373093 -252114067 839055918 666887594 -789106591 76683098 193115110 418576226 -355437815 -597301626 824330818 -659999708 -681328967 -577891879 555799176 -914862432 -353829611 727716387 256353466 100810965 -710416458 85220196 -113039183 184602320 683166242 -318543681 93489313 317391660 -968804698 55498472…
Output: 453563574 -194677243 -194677243 -194677243 -194677243 -495776982 -396175819 -495776982 -475118675 -475118675 -436013657 -436013657 -396175819 -436013657 -436013657 -475118675 -436013657 -475118675 -436013657 -475118675 -475118675 -475118675 -436013657 -436013657 -429221522 -429221522 -429221522 -436013657 -429221522 -429221522 -427067147 -427067147 -396175819 -396175819 -242026378 -396175819 -242026378 -396175819 -242026378 -242669185 -242669185 -242669185 -242026378 -242026378 -242026378 -242026378 -242026378 -242669185 -242026378 -242026378 -242026378 -242026378 -238043524 -238043524 -238043524 -242026378 -238043524 -242026378 -242026378 -242669185 -242026378 -242669185 -242669185 -242669185 -242026378 -242026378 -242026378 -242026378 -238043524 -238043524 -236196828 -238043524 -23619682…

Example 2:

Input: 3280 694780006 375621980 71584046 993822322 -805557339 508553782 -155973147 -349522178 967283793 910370080 -382112596 -658068367 203302622 376583547 711256338 -330664698 -249964270 61608239 -655562493 56737517 665105838 425765197 -571085882 -444950526 975792394 -101003867 -928472943 832695366 -435636780 629381174 -56677105 653678384 -191803462 -331336665 -483042368 -943658570 656717779 831103025 21438612 371551659 -848884253 694397003 -524914104 -956693141 -160675014 796468462 -309886463 -760705516 524566096 991349100 -660117343 366482692 -55628132 -278690256 547766608 -329254799 304569194 -220299781 958046065 203094774 -666653349 -164733201 -658605111 586978311 -991705850 -546589662 812103418 267418421 -943363914 162734997 616325654 -245628538 -947330661 162896629 581333972 429522113 -228…
Output: 694780006 375621980 375621980 375621980 375621980 375621980 375621980 71584046 375621980 375621980 375621980 71584046 203302622 203302622 375621980 203302622 203302622 71584046 71584046 61608239 71584046 71584046 71584046 61608239 71584046 61608239 61608239 61608239 61608239 61608239 61608239 61608239 61608239 56737517 56737517 -56677105 56737517 56737517 56737517 56737517 56737517 56737517 56737517 21438612 21438612 21438612 21438612 -56677105 21438612 21438612 21438612 21438612 21438612 -55628132 21438612 -55628132 21438612 -55628132 21438612 21438612 21438612 -55628132 -55628132 -55628132 -55628132 -56677105 -55628132 -55628132 -55628132 -55628132 21438612 -55628132 -55628132 -55628132 21438612 21438612 21438612 21438612 56737517 21438612 21438612 21438612 56737517 21438612 56737517 567…

Example 3:

Input: 2819 877981519 945915563 -490620583 639812977 69253568 -234869136 838908044 48423816 -577948255 558529597 -42432315 660234924 -546739983 -20048759 248475869 767580737 -69920121 415473147 -660808217 -927579860 603136683 674111698 -373810998 -219199257 327277937 -810068549 -927098965 725940713 -827839347 385033440 642693909 958603329 627419058 -952489339 559045076 -205402586 508218999 861218938 766654529 -849439342 -375591055 -635390194 -969257091 635127331 263824489 -768617527 -935323883 924003425 999053318 -447635311 -408930752 593958681 976788565 648704722 157422252 975265927 -447441226 697051649 358106332 591198620 688570176 33064664 546682010 752455760 508611702 -964495162 -356765998 971111462 -310197680 -614819348 532812938 616689404 51077167 513663007 -862056005 971400588 -545115887 -…
Output: 877981519 877981519 877981519 639812977 639812977 69253568 639812977 69253568 69253568 69253568 69253568 69253568 69253568 48423816 69253568 69253568 69253568 69253568 69253568 48423816 69253568 69253568 69253568 48423816 69253568 48423816 48423816 48423816 48423816 48423816 69253568 69253568 248475869 69253568 248475869 69253568 248475869 248475869 327277937 248475869 248475869 69253568 69253568 69253568 248475869 69253568 69253568 69253568 248475869 69253568 69253568 69253568 248475869 248475869 248475869 248475869 248475869 248475869 263824489 263824489 327277937 263824489 327277937 327277937 358106332 327277937 327277937 327277937 327277937 263824489 327277937 327277937 327277937 327277937 327277937 327277937 327277937 263824489 327277937 327277937 327277937 263824489 327277937 2638244…

Constraints:

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

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