CT23975

The Distance Order of Keelwind

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

It is audit day at the shipyard of Keelwind. Parth spreads the crates records across the table and picks up a sharp pencil. Task: Sort the array by absolute value ascending; for equal |x|, the smaller value comes first. Print the sorted array. Input format: First line: n. Second line: n integers. Output format: Print the sorted values space-separated. Constraints: 1 <= n <= 639; -1000000000 <= a[i],x <= 1000000000.

Example 1:

Input: 340 313120258 112077359 737856909 579343251 -149040356 247784727 -517304320 763523481 -699775883 -995240664 339075363 311862334 668656223 395118977 -907077536 -282591557 981528495 -463341196 585635636 -506639670 -931118647 -971145029 -299622638 -510531054 832819660 -638247259 364617648 668285902 655070882 -360937039 -973577828 935428353 746476234 884930218 505978923 878574178 -741693711 -601956456 -982910686 928429374 492203852 -385822460 -280998050 -584460094 -267308014 -838874165 581585079 459007348 -727187786 738248830 682125118 361665891 790909549 -489936532 -38283731 212599146 -794062164 999026395 -233239084 965641271 852514495 -554116801 -862619564 -71660346 -215015774 -754489036 609655689 -473785920 -340815740 117385930 -845394433 480169987 537062862 -744106039 209761158 -451001903 …
Output: 592787 3638368 -12855455 -33225864 -38283731 42988585 -43641731 44263724 -46666658 50217808 -50529796 50730359 58393220 -59312818 62558096 65642020 -65713470 -67510729 67667727 70604538 -71660346 -77657163 79794098 -80204125 81870843 -82847475 83511171 -84320058 89176415 91972144 -92783768 -100211802 100819613 -101673250 112077359 117385930 -117801666 119549462 -125331012 132711930 135713303 -139815251 141760915 -149040356 -153198302 157216380 157827825 -158806349 159027869 160625669 -162228406 164408624 164884366 172873199 -176233164 176965624 180583016 180689368 182670613 184530452 -190042124 193958685 194949072 -202336479 205877493 209761158 212599146 -213005751 -215015774 -215987976 216454628 -221898598 -228061332 -233239084 244202836 247784727 -250330553 -257724043 259745107 260292259…

Example 2:

Input: 311 928583602 -383502449 96875480 -893457027 291383341 -807733487 601671570 -376700768 39506791 -244140309 -142333209 -8500471 -475686333 449027499 -732176713 -216474660 134436290 -572650757 496705874 -407944016 -207299171 -962251847 928495833 -604851463 -670770467 325170417 446637808 -944773486 184191528 -525372704 71450800 -59545420 -967211972 -585997764 772590058 -880207089 75385412 989239831 -878354127 -639324624 -799449894 -776791315 280136864 -429476851 -354932714 -288615598 186497844 -668843465 152988769 709414547 -154962286 -544238573 -125035775 679237054 159067319 926924450 73253714 -548815003 10730608 93474770 416241473 582461239 -469056825 652748952 -990137352 725719020 798715970 16301880 651138088 -673079249 -375021945 -26546605 70117110 -218004682 -39677809 -82917192 757980106…
Output: -8500471 10730608 16301880 23246398 -26546605 -27085225 -37686382 38619596 39506791 -39677809 43992954 -54275536 -59545420 -61207177 63348939 -67584982 70117110 71096440 71450800 73253714 -74737219 75385412 -75975538 -82917192 -84269289 -90537437 93474770 96875480 99965882 -100034457 103894601 -104295123 105035305 -110549228 -113933657 114655906 118423670 -120373253 -122453831 -125035775 127645571 128858002 -134327728 134436290 -135193253 -142333209 151711062 152988769 -154962286 155061437 -155349169 -155408605 159052193 159067319 163210032 170077270 -171263679 -172071073 -180543654 184191528 186462218 186497844 -191492976 -197323560 202761242 -207299171 207583601 -208033950 -208403283 208502972 215104355 215331044 -216131588 -216474660 -218004682 -220440382 225129099 225680286 -226715883 …

Example 3:

Input: 335 311750117 -477421181 874101217 -262401185 572423277 -135775230 555671319 8759220 797941526 930774372 -199910074 993018116 648366316 223863482 125498943 782421708 784793997 167339817 -719509278 363308488 858436535 588987627 910889630 854231020 -823807922 -350412925 -243286062 -144258574 -931124465 843286041 617553640 -908199658 -85627011 -293176014 323468701 109823253 102015263 66451311 -630736599 233020349 -789903382 -745054902 -952371918 -280853664 413853643 -755413015 54441936 -807734854 533652559 -583458265 660933377 586699094 -83340881 950015540 -391620415 -166565797 144568527 333893251 569235444 -47632490 375026927 -196538047 162487203 -981983522 132288837 -680301225 373897386 329624497 192037187 339017810 215669908 429037601 683579860 584914230 -34866366 301332294 972238069 -9584…
Output: -7781481 7885322 8759220 9003635 -11484748 -13123929 -13857133 -26275603 31292341 -33213194 -34193865 34671482 -34866366 -38654266 41695250 42911906 -47632490 -51974195 -52615411 54441936 54679530 58778154 64497532 66451311 -72697757 -73156606 73345964 79930506 -83340881 83358035 -85627011 86591328 97604945 -101448654 102015263 -102579639 -103683811 109823253 -120961775 125498943 125727863 -131496836 132288837 133095494 -135775230 -139256049 -139660334 -141543868 -144031678 -144258574 144568527 145882070 -148247408 162487203 163312429 -166565797 -167245123 167339817 -168379923 -176672703 -182024499 188598526 192037187 192057385 192295996 -193525852 -196538047 -199910074 202393933 204545881 -209483404 210108970 210313647 212605247 -213658253 215669908 -215767261 -217374209 218196263 -220767…

Constraints:

1 <= n <= 639; -1000000000 <= a[i],x <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
The Distance Order of Keelwind - EASY Coding Problem | CodeTikki