CT58031

Tinker's Solar marks

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the dune sea of Caravanrest. Tinker spreads the marks records across the table and picks up a sharp pencil. 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: 1032 -626451798 812477444 -645001035 950626621 329853789 -895105606 -168795966 -827703854 -392120485 -854662834 224057205 107446764 -728934997 126694158 -29107316 -910074824 -948987357 -790807257 959746006 36794404 215749908 505608483 728831225 916868334 -622622579 -205617334 -154642526 -649627228 487127906 798977114 680025874 -983693683 -470567068 163243661 879713048 270183789 -524141991 -526023087 -169560498 -954141111 -814940694 863014153 173778779 312593094 406687277 49557500 53370261 -688235229 830907716 -432719074 -824818071 -184742768 394044443 -182206573 388819113 -221334525 -409304519 -841561297 -941821951 -328813089 377878520 -770995801 -963635701 697197807 963481472 -721988922 378387595 256170248 31466401 401922195 215994449 63641449 983796173 -734275260 704155412 -740853220 -20…
Output: -626451798 -626451798 -626451798 -626451798 329853789 -626451798 -168795966 -626451798 -392120485 -626451798 -392120485 -392120485 -392120485 -392120485 -168795966 -392120485 -392120485 -626451798 -392120485 -392120485 -168795966 -168795966 -29107316 -29107316 -29107316 -168795966 -154642526 -168795966 -154642526 -154642526 -29107316 -154642526 -154642526 -154642526 -29107316 -29107316 -29107316 -154642526 -154642526 -168795966 -168795966 -168795966 -154642526 -154642526 -29107316 -29107316 36794404 -29107316 36794404 -29107316 -29107316 -154642526 -29107316 -154642526 -29107316 -154642526 -154642526 -168795966 -168795966 -169560498 -168795966 -169560498 -169560498 -169560498 -168795966 -169560498 -168795966 -168795966 -154642526 -154642526 -29107316 -29107316 31466401 -29107316 31466401 -…

Example 2:

Input: 3412 367085725 842170857 -212935335 -325222663 265479089 -437238050 -716714170 60602826 174552098 -548246698 -136540 -622289302 854883428 -36653666 232143393 -105451004 -588989043 -965888180 120746144 914147910 -821737573 -453963116 -780879800 -558290327 569821343 612519148 448019961 -799516820 -237014804 -764763366 298619395 -880715117 715265351 750773543 425165671 -157859264 -854541128 -390085993 282934809 -986755384 722990988 -52586155 -50329346 -980078131 -972196621 -739535204 991200666 -77486873 781535664 -356328469 181440005 820338541 360062949 551805515 556718844 -685120551 -535999020 -25029849 91356915 131118351 372383878 859307215 256096861 302142904 -593239276 427378979 538642057 66709190 924322036 -496653176 -980445542 586745313 -428924683 71318604 -133616855 840332176 -75580727…
Output: 367085725 367085725 367085725 -212935335 265479089 -212935335 -212935335 -212935335 60602826 -212935335 -136540 -212935335 -136540 -36653666 -136540 -36653666 -36653666 -105451004 -36653666 -36653666 -36653666 -105451004 -105451004 -212935335 -105451004 -105451004 -36653666 -105451004 -105451004 -212935335 -105451004 -212935335 -105451004 -105451004 -36653666 -105451004 -105451004 -157859264 -105451004 -157859264 -105451004 -105451004 -52586155 -105451004 -105451004 -157859264 -105451004 -105451004 -77486873 -105451004 -77486873 -77486873 -52586155 -52586155 -50329346 -52586155 -52586155 -52586155 -50329346 -50329346 -36653666 -36653666 -25029849 -25029849 -25029849 -25029849 -136540 -136540 60602826 -136540 -136540 -136540 -136540 -136540 -136540 -136540 -136540 -25029849 -25029849 -25029…

Example 3:

Input: 609 -772631419 -129386395 -885731886 -568559344 76832296 -243127383 738442871 192529900 -821661918 344784009 600776446 84723020 -992492149 -669482037 -307968582 889923931 543283455 -854735808 877106604 657535393 -717409909 -424362250 597020729 586504950 252835730 200358069 -114522290 642818282 777946663 676964356 -696614701 -16214982 111127948 -148299249 842092201 865672898 -567659174 715362337 -963563629 -590661255 -473775534 522608011 -539412013 595355696 -922238106 -270875856 -29014000 148604252 -809900266 959477012 -609243855 746208032 199590791 -441362450 670388417 -774640042 -721589501 654829811 -119588715 338794490 81615936 232539070 -575581871 577877729 279247033 299170877 -59953412 -382742172 -379199352 -848394083 715309049 665433539 -65193006 669912821 283809257 -689706573 589018…
Output: -772631419 -772631419 -772631419 -772631419 -568559344 -568559344 -243127383 -243127383 -243127383 -243127383 -129386395 -129386395 -129386395 -243127383 -243127383 -243127383 -129386395 -243127383 -129386395 -129386395 -129386395 -243127383 -129386395 -129386395 76832296 76832296 76832296 76832296 84723020 84723020 84723020 76832296 84723020 76832296 84723020 84723020 84723020 84723020 84723020 76832296 76832296 76832296 76832296 76832296 76832296 -16214982 -16214982 -16214982 -16214982 -16214982 -16214982 -16214982 76832296 -16214982 76832296 -16214982 -16214982 -16214982 -16214982 -16214982 76832296 76832296 76832296 76832296 81615936 81615936 81615936 76832296 76832296 -16214982 76832296 76832296 76832296 76832296 81615936 76832296 81615936 81615936 84723020 81615936 84723020 81615936 …

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tinker's Solar marks - MEDIUM Coding Problem | CodeTikki