CT44023

Fiora's Vermilion Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the railway depot of Cinderline; Fiora weighs the day's registers manifests and starts the calculations. 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 <= 3717; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1181 1135 998 590 332 821 441 552 994 654 635 434 1102 1064 178 324 426 536 66 197 328 895 636 420 469 807 1029 1163 617 1104 1058 934 799 741 106 276 534 313 535 427 796 951 1110 618 1145 973 1043 280 610 502 1108 1041 628 851 1162 430 874 1141 1177 433 134 146 801 225 14 587 269 455 1074 714 114 431 44 742 222 195 838 909 1140 859 3 0 1133 876 250 205 958 1039 1042 579 599 982 584 576 1003 449 391 649 217 1066 545 772 303 338 1100 417 252 244 1130 679 699 67 156 889 477 871 634 822 1180 216 5 1174 8 36 64 1065 491 340 517 466 272 718 852 787 208 1114 894 1139 1120 13 46 77 751 262 189 457 501 939 448 858 927 719 233 592 989 802 785 788 25 722 629 1094 342 229 170 181 632 956 697 601 703 409 744 1060 986 707 50 1178 454 1007 864 1115 283 778 1020 317 162 404 1169 672 651 354 263 1038 284 …
Output: 357945

Example 2:

Input: 1708 390 798 610 1371 286 1410 1681 1570 118 1197 379 83 180 920 729 254 668 305 396 726 1242 74 523 353 401 1460 513 1000 1374 818 450 1174 808 1036 567 1396 819 216 632 1648 71 968 1640 533 251 1240 817 705 838 474 66 658 335 1176 210 911 476 304 1283 1702 847 893 1200 228 629 368 458 272 1312 914 936 1131 755 59 168 1541 158 112 372 1032 1070 801 399 1137 1611 1341 417 1040 1697 1448 492 10 174 488 1233 696 98 900 336 479 1553 1506 386 1149 1556 531 721 1354 1621 408 712 1565 443 1672 871 125 861 892 128 1605 1124 638 1420 376 976 478 260 250 541 309 1682 1560 1500 1255 1175 337 211 1231 1111 1370 733 646 1278 810 432 400 1220 1368 562 1249 1599 832 1705 1082 1199 12 515 503 642 1078 1173 688 1266 323 1686 941 821 1207 1270 380 883 1129 514 1415 297 989 582 457 1302 643 820 929 1134 129…
Output: 736413

Example 3:

Input: 3401 358033771 589908518 164065006 719839829 197482382 906181167 714808739 805492430 10838011 387790755 235710136 168539882 368540903 715230057 61706023 336250848 390265547 778208040 731111202 255030813 217126844 368286500 713164324 904802138 21996866 604706000 796147286 637136293 72559339 367108783 720752407 652974911 285360587 302525639 193236268 411371563 298426141 257163612 558023983 14096356 948868180 239078755 276446522 166001681 327953805 544077605 505265319 289460586 678658256 851658316 818464685 462417302 427736368 751853453 826681298 939345394 90909077 675071900 67712480 292726307 818458721 673568664 58332004 319893287 305323940 762269424 499514815 191993989 24571231 42276983 118599663 952265186 638217824 193464335 437108102 694213715 135908651 151211569 1051645 926614077 9555650…
Output: 2822681

Constraints:

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

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