CT23619

Trader's vials Distance Order

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the shipyard of Keelwind, someone must outscore the rival chapter. This year the task falls to Trader, armed only with the vials register. 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 <= 924; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 315 113262 819574 -773291 990768 835814 -817326 -81381 -10428 452886 -567658 -395361 -949362 -953474 -700026 -557520 830897 -294523 -879981 732848 3929 93681 278732 -300552 -448762 960811 -502717 -413893 -737481 21101 -576155 930364 180980 493224 -843914 606896 571144 192299 -163800 921439 -599167 -647288 -245750 -903344 -339027 602204 -268035 -370615 -574362 -723671 -316869 -855235 -41244 681690 7633 760581 -761994 -472546 -62062 450763 253573 180483 548767 480128 348287 50675 558816 811950 -960886 -759861 564587 800671 880038 -994637 293603 -600844 -313503 -196425 47956 -81239 491609 -306236 216070 -331145 -936281 -543741 235573 145622 -439620 449852 -336910 704260 800358 -466019 135996 -440766 -387181 600271 -41917 -524327 371775 -79506 437144 190867 -116028 477651 -764810 272918 538433…
Output: -2873 3929 7633 -10428 -12246 -14169 -14667 -16395 -17997 21101 21280 -23780 -30600 32072 38815 -41244 -41917 42126 47956 50675 51313 -62062 -64036 -73474 -76964 -79506 -81239 -81381 81904 -91499 93681 -97704 -104252 -110571 -111782 113262 -114398 -116028 -120152 -135461 135996 137015 141025 -142728 145622 156915 -163800 167764 -178670 179621 180483 180980 -187034 187486 188810 190867 192299 194801 -196425 -205154 208982 -211986 214748 216070 217086 -225920 -232261 235573 -235715 238245 -240172 -245750 253573 -254772 257228 -260542 262225 -268035 272918 273574 275827 275845 -276583 278700 278732 284006 293603 294289 -294523 -297410 -297503 298306 299288 -300552 -300743 -302279 -305758 -306236 -307572 308358 -313503 -313530 314183 315458 316154 -316869 327681 -331145 -336910 -339027 342192 …

Example 2:

Input: 321 -791395 578817 626665 -184864 -873049 81330 -754933 -437341 -376485 413772 111932 -340469 -939296 -221983 -690202 -659530 860528 -824714 85976 -608758 837133 400093 -13224 200761 76687 57266 -339372 -156904 688578 688375 634780 -841375 -512993 9121 446043 438761 -8530 252149 -791557 112220 -991858 -614899 336989 756003 121553 -639909 312769 -997627 25708 791271 -719596 -656954 -358602 -16971 707803 752356 406692 11326 -204991 -761078 -325637 835491 766319 430628 745848 -637165 -845945 -892473 -334587 -876969 258583 -895055 -821897 760573 -700904 862475 -978035 -451748 94200 588921 -174078 -188320 -350147 -527366 406133 -808836 -790468 24791 -646198 -952794 409276 -834362 -124563 -96866 356146 -858863 331130 -938529 187905 980207 -261461 -422146 -626574 172227 -819142 291111 -764871 772…
Output: 2930 6809 -8530 9121 11326 -13224 14680 -16971 -18721 -18895 -20398 24791 25708 33892 -36235 -37544 -40541 -41095 -45369 45425 49594 -51055 -56672 -57004 57266 69814 71837 -72092 76687 81330 -85619 85976 -86993 -91298 94200 94734 94968 95176 -96866 -99201 99321 -105016 -106847 107768 110881 111932 112220 -115739 118152 -119163 121553 -124563 -130472 -134416 136587 -148956 -156904 168650 172227 -174078 174781 -175337 -176728 -184864 187905 187939 -188320 188522 -188666 196625 197162 200761 -204991 -206083 -206414 -215901 -221983 -225859 238861 244322 252149 258583 -261461 -263181 -265551 266194 270279 -273265 274629 -276072 -281562 -289831 290452 290525 291111 295373 297813 -300769 -303384 305331 311625 312769 -318282 -325637 327216 331130 -334587 336989 337750 -339372 -340469 346557 -34893…

Example 3:

Input: 535 305457 875884 374505 -102112 400943 567535 -529901 218786 -39078 418916 -348916 555429 -470249 -127471 -774192 -522905 -975251 -978546 567904 -827711 -462835 -76377 -702552 -139874 -477612 -973222 -302365 -329886 -120275 401800 -488766 634105 -727235 -691948 122696 -228737 -373703 -168379 84804 506481 -248417 -753887 -584512 -723857 -164368 -547703 -624787 968953 -314000 388405 675226 -383580 781094 -297614 -973508 546975 -178709 -834736 47127 -262769 211314 -4867 -446944 939903 -86436 119726 -505384 37241 -760248 467000 920337 -646732 -828159 614125 749382 -539283 503669 234841 -184839 480711 395854 -761612 -448343 -853984 703968 272445 702231 -562652 89075 -355602 -81176 -371985 169396 33654 -422368 -922379 430578 217028 -839357 824026 -136038 -826342 609278 -264578 -165658 -221770 8…
Output: -4867 -5796 -7764 -7901 -9840 -16588 -17700 -17897 17936 -18467 -22599 25753 -32078 33654 37241 -39078 -41065 -42615 45670 47127 48493 54540 -59040 -61140 -62594 64100 65221 -66678 -68251 -69083 -71866 75441 -76249 -76377 77751 -81176 -81387 -83429 84804 -85484 -86436 87335 -87985 88458 89075 -89361 91061 93685 -94573 95728 96171 -98277 -102112 103795 -110450 -110535 -111587 -114167 -117250 -119567 119726 -120275 121579 122696 -122752 -127471 -129675 -132915 -136038 138738 -139095 -139874 -140059 140078 -147416 148731 -148949 -151725 -153046 -157666 -163366 -164368 -164636 -164812 165534 -165658 -168379 -168438 -168958 169396 -171122 178415 -178709 182072 -184104 -184839 -186724 191220 192558 194258 -196691 199866 -201522 -202517 -205418 205598 211314 212138 213852 -214191 -215339 215891 2…

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Trader's vials Distance Order - EASY Coding Problem | CodeTikki