CT61038

The Disorder Count Beneath Bloomglass

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the orchid house of Bloomglass pays by the answer, and Silas intends to earn it. First: the full register of ledgers. 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 <= 3674; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 2980 -533896 -675507 -15865 -82960 -787978 -328615 -984137 -245374 -556403 826182 -101971 14158 -74430 415621 -47363 266747 385623 -588222 -263373 -344452 386902 -876931 975807 569646 -218205 812463 777467 -163601 166161 470624 587737 438020 -491615 -137584 -297798 664462 353388 -337837 868260 -780703 732522 -73245 111586 -247531 152756 -577728 143388 -576041 455470 -89333 747493 511502 741650 749350 872988 439291 785335 -59448 -249320 -411631 -816854 964322 388667 -795903 907045 863100 -802702 287295 -853270 -59436 -411173 -334597 -182067 -645677 -397119 -44119 -383000 575792 -862223 -428898 76274 27602 -587266 955150 884650 102447 334388 261109 422159 -609366 89269 157957 -667568 500025 -519690 -678624 -443324 6097 -850342 309187 -568044 -429967 -229229 362930 158081 -626613 -957025 -552…
Output: 2206827

Example 2:

Input: 1006 957902 716146 901569 -979604 961726 599164 -567637 -209699 -10527 -145067 759332 -165379 12848 -81291 -821894 181171 851754 -271118 -921922 -815254 261908 -652428 -400013 -810009 -543234 -817866 -279057 210282 716568 -960494 -217818 -89446 -574075 454320 -298091 -536068 -486862 533007 39724 322094 -450648 -334895 -127393 842219 -663815 -62755 -506816 526958 -172241 -583076 61143 -982462 -673369 -629373 873020 -564616 -729558 679728 205891 550360 168380 -804482 -238002 326931 -78750 845255 587701 -432656 274903 282170 -516574 -842835 -188129 -466090 -497031 535554 348278 -826309 453170 -754366 -806668 -882755 -992624 -39257 -294531 -88657 -419214 398654 -348082 524626 496269 -999951 712640 70142 622593 673183 -485373 -779620 495363 810263 -466890 -910802 -842745 662209 -739399 -833136 …
Output: 243197

Example 3:

Input: 711 959827 148793 -511978 617416 -647607 -682901 515250 -407935 -491902 957622 532002 -648381 963771 -400327 205768 -612775 -6080 -149737 557658 -313967 421977 32131 83477 279910 -296559 -202030 -149163 379308 -522476 -805326 887368 262356 -353056 96065 -259523 -655247 358875 -509120 782391 -794839 325836 -542312 917585 955154 -979850 -626187 -355860 -651599 -686057 -782886 633803 -923077 610137 637120 675127 208948 8419 -880865 -91589 -446349 241019 882693 -745643 -836616 242497 -360215 650178 -807828 787611 -564088 855451 884108 -573773 31090 31972 -94027 -205421 514299 -506514 462267 13241 384842 994231 170932 193424 -757470 330426 -537033 -312711 -299591 -305874 -103798 -849268 -432931 -146882 666509 469466 -271183 459169 500505 -949471 -367667 653364 555021 14508 93893 314517 -830436 …
Output: 127152

Constraints:

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

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