CT46768

Jessa's Disorder Count Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the zephyr cliffs of Galeholm, Jessa studies rows of weights entries. One clean number will settle the guild's oldest argument. 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 <= 3480; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 382 -560690 -293903 179644 548915 -886898 196459 126884 207166 519206 -872374 -489350 135535 -891759 -554873 463111 955731 311328 -59548 -465551 210423 -547376 238642 122649 906501 882013 -332731 594347 20896 -621485 -146020 836542 -46711 -667799 111743 -592735 549992 49235 238508 -566230 444674 -305538 2127 -490667 -172433 911424 -72519 158016 489533 935990 686759 551206 369718 616785 -61147 59235 117477 -848078 -624047 944572 -681451 -156666 -708262 712180 -168825 66342 -260710 254674 -31014 214933 982526 -25820 198074 687917 -944324 -109615 877298 796264 14258 -359690 384856 145436 351815 703148 -821019 -857806 -232547 -269248 -974106 840453 314645 -774315 -619645 136770 -711363 497 -842300 279499 -424413 -944531 980715 143456 194976 439488 45698 849349 127559 323854 977827 796713 -4625…
Output: 36024

Example 2:

Input: 1113 -693506 -486308 835653 -120390 831555 -60078 -863703 377429 171237 873001 -18789 92922 -162267 -893994 -976901 -575633 383878 375163 354288 -830595 345541 25802 -951224 148125 -562099 21211 110468 493755 -322670 -656528 -411620 -279294 290979 -564370 856218 422894 -193760 -354875 727231 -108275 788382 110315 449333 312982 785432 -275950 454715 978273 782443 16069 -981091 -39096 977919 -275784 -707657 502222 -968743 -643333 573166 38549 -64934 -808033 -613630 -625014 -879043 508087 -4599 -229937 655941 -905087 -241292 195582 -733999 965627 -756642 535806 -553201 -75794 881230 132545 742676 -868427 144847 -153586 -292179 680002 338348 959529 967536 213791 246976 -673562 -822420 -3140 -595369 416583 336422 -613433 140519 1239 232095 94617 -561594 680609 -874474 -428960 487439 297195 -914…
Output: 307332

Example 3:

Input: 2107 404151 -574872 -925020 -509734 309189 984606 -384796 -666369 812173 -807619 77897 627306 275463 600716 503503 -581088 699475 -702306 243547 216057 486668 -624822 618193 -101308 841687 -276976 -715779 -514398 -608454 -555474 -526805 370862 624355 -646548 110628 -829441 -222674 -260161 -240235 327520 31662 -787624 -782538 -838442 671819 -669013 813056 -276724 155843 502600 584273 -16264 610739 842533 -497557 -806396 -621305 -750803 653642 783745 -960040 -915979 -335884 902879 784804 -662413 631549 608759 913180 441164 -84481 -149246 66995 -271953 -102909 -341651 955114 887876 -974723 -453790 -515935 -351087 695171 228570 -145354 342440 381918 -723968 240773 -209687 -875660 587679 92340 -60065 -867962 512583 265462 686686 -26917 -240885 101328 19417 931329 96199 -145109 105518 196209 847…
Output: 1093447

Constraints:

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

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