CT53076

Nico's Golden Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the steppe camp of Horselord Plains, Nico studies rows of crates entries. One clean number will settle the guild's oldest argument. 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 <= 2183; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 1031 939577669 168114944 905953765 322115804 56427187 895669230 829508709 348124486 574227444 89434595 304291712 746368874 273341840 756364315 474720304 193637090 398743943 37896065 333940403 597522662 473019709 85290251 626210747 378974958 436283435 568286761 3036261 710030265 291105197 692846259 71835739 782584107 72829038 249643739 243200762 826584462 395600801 512202392 208647721 275619666 44780427 708062710 285879331 625305356 721367405 943103330 837870540 849223460 515653008 660899262 755129135 913991468 398089334 243229862 346108055 833072820 248921030 440963489 587261479 379236905 203573072 288338995 493417530 222247943 425949308 15007108 48628900 172672848 285005112 194757338 622917735 87279510 228617654 60358601 274514055 315573516 882374843 791551797 91735786 579351473 391417219…
Output: 270932

Example 2:

Input: 30 302973863 117391797 26817566 785181802 346696228 379986951 972516023 608334022 991286172 615690377 771515481 844564957 371227038 978410106 272656551 232798386 780459084 316460965 896982300 99281113 97939695 869598307 737021767 869689346 190133333 340880262 516039355 246558961 29263213 187784690
Output: 244

Example 3:

Input: 1837 1721 1297 836 84 423 809 1821 422 1588 36 322 1372 1177 975 1091 1329 647 418 1483 1509 714 669 460 1453 715 1205 956 276 807 939 1728 993 165 666 1090 649 1582 264 1363 1455 1311 1282 1711 189 1088 1365 332 693 1715 1431 1447 439 1285 166 1351 1593 1523 324 1604 1465 871 1828 1105 1013 1524 1730 34 1185 1533 589 965 88 654 1001 1675 462 1672 650 148 1722 1572 1024 447 282 1158 940 786 1623 1436 695 170 887 1097 1737 411 392 479 1550 771 1109 1827 516 1428 1595 1218 708 790 337 1546 1171 1009 1495 1461 1647 1370 1633 1332 612 732 1341 203 610 499 1299 440 1554 1606 1058 1004 906 77 209 681 1219 104 1044 72 306 795 383 477 1230 125 622 1253 270 32 837 780 158 320 1325 1108 1025 1069 863 704 283 1496 273 1709 1551 1835 453 1195 415 437 3 29 1292 804 989 829 1101 550 832 994 1233 101 150…
Output: 840807

Constraints:

1 <= n <= 2183; 0 <= a[i],x <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Nico's Golden Ledger - MEDIUM Coding Problem | CodeTikki