CT21942

Timeworn ledgers Distance Order

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the heron rookery of Longlegs opens only for a perfect tally of ledgers. Lakshya means to find out. 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 <= 456; -1000000 <= a[i],x <= 1000.

Example 1:

Input: 244 -422940 -357793 -192379 -4086 -526172 -371202 -805753 -602682 -461840 -793401 -123295 -792446 -769862 -890409 -649297 -7228 -718671 -780245 -370678 -226504 -455884 -302370 -810058 -457351 -127841 -98052 -504361 -500911 -682551 -520140 -345775 -393139 -255246 -570725 -608262 -863362 -161905 -780272 -390094 -960200 -20993 -234397 -194788 -648010 -662809 -850868 -91531 -371263 -69640 -71871 -426086 -543050 -313025 -195872 -51329 -539786 -843276 -725427 -769820 -35467 -417212 -978214 -819931 -645241 -901504 -915604 -48066 -126942 -594156 -775390 -525333 -650506 -939215 -197798 -543779 -22958 -147944 -252977 -710624 -957786 -403696 -574220 -687719 -591134 -504572 -59683 -725004 -407468 -537538 -800129 -893255 -726004 -617694 -684349 -296290 -973576 -509722 -777690 -351029 -233399 -312791 -3…
Output: 55 -4086 -6575 -7228 -20993 -22958 -25784 -29544 -35467 -37036 -37598 -42330 -48066 -51329 -56729 -59683 -67730 -69640 -71871 -81069 -83786 -91531 -94243 -98052 -103090 -106496 -110695 -123295 -126942 -127841 -134581 -142481 -143705 -146471 -147944 -150127 -150447 -159650 -161905 -171598 -192379 -194473 -194788 -195872 -196136 -197798 -197868 -207520 -209549 -210054 -219963 -226504 -233399 -234397 -235930 -238371 -252977 -255246 -255635 -271204 -275536 -288467 -288494 -291706 -296290 -297960 -302370 -303318 -312791 -313025 -315125 -319289 -327011 -329405 -331624 -342447 -345775 -346756 -351029 -357793 -370678 -371202 -371263 -374307 -382618 -388837 -390094 -393139 -399521 -403696 -403972 -407468 -409096 -410948 -412992 -417212 -417924 -421028 -422940 -424737 -426086 -428009 -431313 -455884…

Example 2:

Input: 192 -567392 -403686 -688023 -858295 -674010 -671487 -292821 -433941 -354784 -489425 -563131 -536306 -571875 -281996 -584303 -10119 -947709 -793417 -610661 -580718 -460718 -201962 -734802 -850388 -379739 -387142 -623630 -18787 -33503 -995866 -89292 -960986 -743488 -176154 -135125 -172401 -556183 -560325 -689169 -168640 -499570 -390702 -409433 -985972 -410522 -305073 -768303 -552757 -477973 -456585 -956820 -537779 -364610 -913395 -960063 -92631 -964580 -952465 -876531 -640537 -239923 -708320 -878634 -855314 -430262 -563284 -535862 -308778 -316283 -425278 -207290 -636678 -495044 -618566 -970408 -195873 -202084 -238048 -784917 -101097 -32481 -999448 -56210 -138632 -662645 -140580 -872459 -60163 -66140 -82004 -722479 -36792 -260207 -741689 -806919 -631061 -43305 -425037 -43631 -423353 -208925 -…
Output: -10119 -18787 -19061 -32481 -33503 -33668 -36792 -40437 -43305 -43631 -56079 -56210 -60163 -63982 -66140 -72785 -73568 -77148 -80061 -81097 -82004 -86562 -89292 -92631 -99036 -101097 -112935 -130295 -135125 -138632 -140580 -144426 -145814 -148978 -155228 -168640 -172401 -172928 -174196 -176154 -188339 -192036 -195873 -201962 -202084 -207290 -208925 -211498 -232053 -234684 -238048 -239923 -249870 -260207 -281996 -283569 -292821 -304326 -305073 -305908 -308176 -308778 -316283 -319948 -323779 -330452 -333595 -336582 -338920 -340924 -354784 -356906 -364610 -374938 -376237 -378916 -379739 -387142 -390702 -403686 -409433 -410522 -420021 -423353 -425037 -425278 -426891 -430262 -433941 -437239 -450493 -456585 -460718 -470345 -473788 -475352 -477973 -481814 -486414 -489425 -495044 -495119 -499570 -…

Example 3:

Input: 71 -694372 -302425 -866314 -471427 -571307 -246971 -940334 -340939 -55522 -641950 -296501 -717750 -396714 -678986 -267849 -378942 -423643 -659923 -253941 -251610 -252364 -216596 -106809 -51781 -88078 -607131 -899162 -991705 -540947 -589829 -724213 -71252 -573101 -39603 -209925 -728143 -298943 -359870 -656186 -446073 -483137 -55015 -848199 -357809 -92023 -715015 -70274 -312747 -241857 -499411 -971114 -704492 -430412 -898261 -526801 -453143 -964211 -346753 -74797 -922337 -498485 -983925 -937480 -331058 -865611 -283354 -824632 -961030 -836137 -375124 -274932
Output: -39603 -51781 -55015 -55522 -70274 -71252 -74797 -88078 -92023 -106809 -209925 -216596 -241857 -246971 -251610 -252364 -253941 -267849 -274932 -283354 -296501 -298943 -302425 -312747 -331058 -340939 -346753 -357809 -359870 -375124 -378942 -396714 -423643 -430412 -446073 -453143 -471427 -483137 -498485 -499411 -526801 -540947 -571307 -573101 -589829 -607131 -641950 -656186 -659923 -678986 -694372 -704492 -715015 -717750 -724213 -728143 -824632 -836137 -848199 -865611 -866314 -898261 -899162 -922337 -937480 -940334 -961030 -964211 -971114 -983925 -991705

Constraints:

1 <= n <= 456; -1000000 <= a[i],x <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Timeworn ledgers Distance Order - EASY Coding Problem | CodeTikki