CT64197

The Disorder Count of Brimstone

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The customs officer Tomas has been asked to fulfill a tricky customer order. On the desk lies a long table of weights readings. Task: Print the number of inversions: index pairs (i,j) with i<j but a[i] > a[j]. Input format: First line: n. Second line: n integers. Output format: Print the inversion count (fits 64-bit). Constraints: 1 <= n <= 1051; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 150 124 41 91 81 126 55 102 60 61 114 73 117 22 89 30 142 70 57 135 92 107 16 71 5 12 113 100 23 82 56 20 15 138 116 11 37 42 137 108 68 144 13 21 90 110 25 40 0 96 101 128 3 32 46 77 98 80 106 105 115 134 63 34 8 83 94 35 44 58 62 118 14 148 132 146 18 121 79 76 39 54 109 84 86 74 9 133 111 67 29 6 47 50 31 51 141 36 143 131 26 10 24 127 48 59 97 139 87 129 145 19 130 2 49 104 125 69 112 93 65 149 120 17 7 99 27 45 72 95 147 88 43 64 119 85 123 78 136 103 33 140 52 38 122 4 53 1 66 75 28
Output: 5540

Example 2:

Input: 250 657391672 953888169 259573960 712085013 793586255 993620591 182137604 621212157 64798508 479681111 344432418 881024546 510176879 439310292 449112918 286542763 13289805 279426074 786944409 465643280 360534365 252465407 88976489 991269760 547342214 273289733 262190730 901866241 862510673 284563548 504099636 903213555 639187047 826293410 916086482 647420130 610937162 980995632 706454143 987644819 267587486 870894653 40507711 114094251 314894342 730545404 399730546 936605962 540433157 372574306 991717342 195563838 22856245 459800453 425197278 93210923 940057069 998686461 858073602 651216075 185230617 458270335 532559570 723579709 827952455 55139676 382788319 967679664 987714463 594182405 433929554 693056169 106964464 821719650 373383559 240619964 729668039 919347162 363194161 202629361 996…
Output: 16318

Example 3:

Input: 1032 898192514 537594640 164387282 470199135 788976602 878904610 227703434 868762566 219634591 969021865 628847966 806266130 8713548 917135285 652106723 806570950 335932005 60092263 671805317 390268823 413104188 940104210 38432937 416901806 987089218 421068701 74686961 158825958 520016245 802096835 565866534 413244010 491462569 110817943 158484769 52709355 371265323 944088903 179196834 470885925 428869953 527644212 993123354 131376202 173143934 913581604 858741820 400052634 942874299 642025327 164273128 877794556 45583562 803136839 576163381 908333109 774374945 552488482 724877622 764664524 879201100 832986883 189485327 541532228 853501805 988348252 626633159 66661965 244234364 945419344 535990887 322228021 459043575 295210470 868466173 451876252 432292634 644555282 343813937 660443465 755…
Output: 264337

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count of Brimstone - MEDIUM Coding Problem | CodeTikki