CT60311

The Disorder Count at Vermilion

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the cinnabar mines of Vermilion; Envoy weighs the day's weights 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 <= 1144; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 19 648286968 185285240 704851252 396456843 134633306 420511586 891303817 744725786 733532248 287858036 929281490 -280767 922394500 553229866 214221184 806905066 534612847 626161681 650085404
Output: 76

Example 2:

Input: 1025 243 385 125 149 585 127 928 443 298 961 626 632 924 302 199 683 846 182 8 491 68 697 375 10 668 445 223 370 470 107 756 877 806 171 524 772 785 981 733 617 631 560 455 798 36 28 414 636 527 289 123 763 76 201 265 402 957 46 448 693 833 321 438 901 319 400 165 364 544 241 985 284 283 565 255 948 902 56 610 703 750 307 204 423 648 341 838 831 635 388 252 533 531 224 805 1012 214 706 441 79 251 356 807 723 413 257 198 269 94 997 776 320 767 969 155 248 31 444 482 828 654 306 225 1016 850 449 661 679 200 510 803 405 946 96 404 644 437 334 268 869 406 884 562 124 102 954 215 553 446 421 647 344 739 64 905 116 714 383 452 211 506 804 861 311 52 365 299 655 980 719 362 151 184 779 824 673 847 500 699 704 339 458 615 359 44 800 67 1003 937 391 873 147 871 605 575 608 732 976 996 891 854 667 5…
Output: 253911

Example 3:

Input: 714 561330108 776829845 707951156 244128266 544196007 783395695 231321952 245963984 733884127 58458236 333871157 15403439 321322570 136913049 756252878 313521603 941301296 235220435 43599676 66395490 832294242 239681679 919764291 200683526 866647903 213312473 842012089 423190748 631461589 240793467 173020169 949143259 325860101 174609935 965671049 665692252 658237056 904631981 9129512 582637998 659849748 125464151 625988883 499961258 551730847 963861888 179175147 897725013 788008436 816063887 101533422 431367373 697051745 664850011 737010902 920675864 910263654 313999618 740205202 172799040 649765732 393385681 92178600 629958933 587414362 366641660 873018849 702702161 279304909 467682591 519043196 250360509 141865267 584032861 896157795 11060900 246219321 680524903 450862009 445493881 7665…
Output: 128920

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.