CT62671

Hope's Disorder Count Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Hope inherited the signal tower at the coral atoll of Pearldeep along with its curious bookkeeping system for vials. Time to make sense of it. 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 <= 3176; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 2821 546793137 41675907 864622902 426366525 175333945 620358700 645736969 179287081 290515051 655294142 966514275 10503665 313376772 156358522 974333421 423436762 708159038 757195493 464198105 522677965 377193103 434167874 773802265 432218930 768241624 43185362 613660714 173780015 641847208 124663949 957068317 542673454 128468873 471927746 34660708 504895444 55888882 833266850 748373697 161743625 126580268 145859378 711132970 165921524 275322991 861688923 328475171 482897191 529112626 945748429 982339587 623030 437993453 24603085 60226492 520060016 644455019 294447479 386720224 363303216 937773755 350910034 281553515 132799498 325543832 556481473 902794483 628886829 236532937 392754060 689942224 165966619 7702873 734375878 514434952 670241726 221421526 232249277 267105844 996163943 6560043…
Output: 2006278

Example 2:

Input: 1653 418751928 901914954 149796658 732534063 62264279 56707846 564626829 436721687 531365820 977805533 348184320 534618150 316845079 521504148 613721128 752229191 736938761 273528822 296639387 478070402 211594992 202805057 145041301 435436868 314647820 901697494 27242663 934180128 411992118 57619022 75543939 388099020 717199315 364276378 511228777 999105737 980108893 569369567 231644494 62108646 354839739 738607091 64976071 384351872 422894006 781420650 409858978 312549135 955944505 523759074 924357219 896420181 735627380 211182027 670738425 325103118 71182335 944110741 199558937 554519473 569439021 847504241 313664217 749899349 403345334 6594207 466815386 530274707 590360523 240674917 77183380 590330063 141945807 200964160 916117454 370956097 720371737 573665419 309389606 472457865 736537…
Output: 689243

Example 3:

Input: 1070 266 591 107 303 806 757 45 880 694 273 344 860 902 931 1051 124 281 751 6 768 914 53 954 723 915 30 276 1062 187 1056 393 1043 94 721 824 604 654 14 121 390 809 988 661 490 358 562 71 214 381 655 523 176 945 419 195 875 720 859 322 765 451 821 1004 725 981 396 1030 93 802 362 912 220 733 671 877 955 347 338 123 411 789 477 967 936 249 292 486 410 142 692 485 528 114 1065 76 189 196 952 699 706 548 879 1061 716 252 99 84 216 377 795 798 796 956 1039 555 697 1047 464 938 442 360 456 611 40 651 235 1003 329 632 994 529 700 135 1054 925 41 354 24 415 610 825 1063 236 512 565 305 647 537 1015 286 269 423 242 896 370 677 718 657 414 907 704 777 524 288 493 641 708 385 342 365 1053 244 499 496 64 1044 501 620 219 146 834 748 1000 254 478 106 487 225 778 799 1029 637 644 835 279 101 883 137 5…
Output: 284258

Constraints:

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

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