CT52821

Hema's vials Disorder Count

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the ink district of Scriptoria close for winter, Hema must finish the vials ledger - one figure at a time. 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 <= 2029; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 2019 289436744 40244595 271070353 438931881 807149309 65288384 795526392 888700061 974644863 474528708 351508197 674442572 474206839 802886172 77453571 81968304 540240302 522493822 929752299 356665033 192748907 941003402 153170056 512633549 69843022 314456426 349677542 592467917 878518469 235379769 853530972 286157712 398433236 430462143 265604459 348120814 91045653 732723075 203982083 295790317 505643295 563490458 718272160 385396463 130879110 34894874 886020356 477938117 351010157 542822775 710610188 801845647 837828982 681718852 529477529 610183856 442293416 65209500 884391469 944428920 46817468 115283726 568998933 108910244 693914220 683691444 654353092 585503672 809967799 737204971 94933211 995231355 164223194 783953701 706184280 140611246 102882010 15437161 649766417 152936227 613780…
Output: 1008972

Example 2:

Input: 868 548907122 584952230 199270122 582890799 232914001 841593543 548344372 187540656 344699348 660563249 156222443 603947226 826209309 196555471 9798222 608541392 139073928 977840532 581880187 561272633 185255159 173035695 273455508 110571375 950484477 969698820 414296972 743323326 244628203 833413649 144654744 733315170 156901056 279078606 873275811 990814 134246484 177956092 987908926 916112704 941926688 450104420 238931367 184274008 989278438 676978427 103798813 206202155 365382574 559829195 386623451 397677158 27002249 770326186 47726616 676542201 450449352 837836998 640637544 915773694 612874998 126031945 614371850 28218973 855982458 273668276 618630583 150763390 172262911 125168693 430725346 436229913 380620194 472064937 369781822 136075484 959403236 190682973 761781548 19140746 25643…
Output: 181352

Example 3:

Input: 1962 1451 1106 340 1558 729 227 1749 1396 359 1044 860 922 646 58 661 572 842 806 1322 1073 1842 1315 801 1877 1082 1399 1151 443 724 510 566 1751 698 1512 274 395 1917 48 1690 1734 1284 129 1013 1394 104 1374 292 45 1845 948 526 841 1490 657 835 1203 887 1312 1178 147 483 1132 262 154 325 1145 311 92 622 810 1123 1465 205 580 71 786 112 1388 1415 1745 556 1762 1444 463 901 975 777 968 1031 1604 385 813 570 1332 1353 1536 1661 1884 731 1434 683 582 1937 1828 215 74 866 412 1202 1336 1627 1903 689 424 1659 788 703 1671 876 1370 7 875 1934 197 1579 332 974 1417 991 36 1189 1118 393 1395 1810 23 1812 1080 1060 962 584 1063 1496 1561 1389 194 1607 544 1504 1241 1342 1383 1251 916 1612 730 737 1441 1759 525 1160 607 1169 1020 279 858 144 1908 972 489 447 433 613 1648 1899 1686 35 1015 1599 369 …
Output: 948492

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Hema's vials Disorder Count - MEDIUM Coding Problem | CodeTikki