CT63561

The Disorder Count of the Hidden ledgers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Every season at the cedar groves of Balmcrest, someone must fulfill a tricky customer order. This year the task falls to Squire, armed only with the ledgers register. 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 <= 3666; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 1539 333238204 246109378 52946521 776178570 611920705 778861859 854853519 123987218 76462477 798360897 554233750 646601854 258273953 615478024 533039829 717314571 519490865 512887586 288144483 449657644 652868526 365522375 490450341 722211315 849172288 668229485 829185795 502122349 734337103 324320549 606407372 850663103 787766234 95709612 57311866 639177657 773680974 228587887 557200453 954423068 162507442 338641083 953534656 962340212 47652701 463669063 992731226 745045806 219985318 546207387 357133498 113096966 418074059 772883216 668772337 705294152 588013334 34566365 742265013 761176842 96607996 969719348 70222034 322662715 982761926 914652145 279092312 6829992 941684380 82514522 226426982 298184856 66452767 12256693 792129308 478546116 476928934 7122665 913392579 24585325 63987085 93…
Output: 596229

Example 2:

Input: 1439 670206736 591938467 627688696 474599960 862963991 324939882 7108257 945633518 357626934 266800700 301558614 399687181 173031695 129363799 669927738 877664517 666442108 489744731 234529966 670079229 601249575 486569479 285784826 927328581 632192151 487170692 280129079 354749409 155780858 890877484 626118196 456253990 529782643 810671057 52069419 92564001 854889286 562023066 570319334 479081553 347848490 394952969 772831825 646844911 999897641 51297021 216169134 594898783 965132401 523819672 951696588 21211689 542174246 93092126 754525574 796518597 136560108 123800116 209886066 801256792 290557972 564018584 497236515 546038820 564536931 880964709 715793235 584688905 572143428 598031123 768884199 432843668 608420666 277983009 973239322 486449164 611747599 759279592 741853691 596059322 14…
Output: 512336

Example 3:

Input: 2599 593776237 974676446 81221821 402315157 738378557 705743249 607208741 538869278 316674468 669044545 534900990 917722063 667056571 985110020 116831042 121489027 709529560 122262812 790814712 645814176 141533193 276410212 68065200 706847563 156731284 198948207 3411904 906549511 133777450 751011846 326764644 816263347 958472456 909970299 415982777 444688854 330054774 699630588 449480777 613297124 631270554 658981024 158047265 853813324 124388644 705305784 794745359 477647954 980994613 985953935 507163780 661732091 80991973 906757707 995449070 194581285 727716530 541818946 566166510 527679077 995780167 174900457 77874491 359873519 362556925 457245857 725005953 155511179 165580759 378739425 626109302 386238195 532680819 16440528 972812877 718293545 482791076 767180274 728171618 728835444 78…
Output: 1665399

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count of the Hidden ledgers - MEDIUM Coding Problem | CodeTikki