CT58935

The Disorder Count of Amberplain

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

At the savanna camp of Amberplain, Rowena records each crates in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1336; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1135 239126094 918609020 640386959 827979480 660344435 530033347 870902257 887185585 139700639 676837370 933041732 239250015 83025540 89953326 669037531 481124988 358142237 929627027 439637092 521588601 749918372 488539801 196888154 626735765 379474346 863846130 710128795 81521356 635830159 95907608 515082245 817635128 992343152 875614915 362349489 697140711 79231025 965380040 55986989 809565280 994486547 221947260 655311127 132736796 514324991 705048377 122871561 705261848 546359273 669451579 385721441 898926300 944673874 756034625 40836405 931847571 571367447 449379147 744255297 152190258 352236125 824714752 596266719 555200153 936251650 423536626 268471965 706402704 914407647 465328319 574434348 815319859 815157998 299545029 950486001 69313036 773539051 971577366 159052337 513685361 782…
Output: 330477

Example 2:

Input: 400 495175991 533695120 676042810 545107626 652554563 361654770 710882765 481231167 935806980 371969654 882428726 87353727 227878971 851692069 245384125 896248142 469126054 983755974 615072669 256207801 427354884 83750939 777597891 648467362 949321972 831743765 772108470 149638075 487140401 397587116 389785152 680646855 295994965 48146591 505586430 888354002 250091793 345421380 547016515 723396922 4662587 568108245 147056326 873444768 423218807 416213235 878525379 838470020 510613017 524326834 190055641 805623734 848051374 556070411 596563747 413217639 780618982 147539481 107170213 7632743 714419061 89777647 440625423 475065213 918217684 133083847 642652969 674465043 658331051 103130238 882474604 670781308 804483900 770315480 902757246 568722194 152952169 956775313 914905392 537314863 8147…
Output: 42390

Example 3:

Input: 634 571907957 95110008 478953221 980385991 127685734 812188838 34765498 509895355 515532460 996305928 139550417 691715022 389996304 862319632 424382002 517421191 921765736 102294844 238773319 848631533 427484226 128803224 202848777 104111942 37633843 868182670 709040649 132493255 231044138 99894190 567088526 835778636 419451077 444063880 583474402 146642901 863554284 29817978 525514892 868774095 400059406 602381317 626499347 619162674 323364018 854962350 501425296 818666203 212855398 425359314 803006344 8113898 541211743 557602855 744199776 38381857 589534978 21556531 358116407 310449634 437988879 405159557 409929619 321817903 78624314 531493172 785319247 442399566 813735961 278686711 180259545 796807154 118924788 565694975 638397977 247663014 692063692 153070454 97789926 13196692 53061461…
Output: 100972

Constraints:

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

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