CT59623

Iris's weights Disorder Count

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the observatory of Starfall as Iris unrolls the day's manifest of weights. The tally will decide the next shipment. 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 <= 3790; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 3725 2833 141 3262 217 2908 736 392 2515 631 1503 775 652 2596 3194 1475 1689 2693 2452 605 3615 2167 3120 743 2625 1947 944 84 8 3539 1594 2757 518 1274 1626 2096 1890 2385 709 1934 702 3628 1402 1060 2565 2701 3348 2347 1370 940 1659 2585 1097 1445 412 1102 2939 3541 3339 3113 67 1534 3327 1656 1461 699 3358 47 358 1554 1532 1327 2853 3659 3199 1515 1736 2527 1796 3191 1309 1231 1333 2533 2115 1105 1314 2097 3424 1960 3218 2556 3382 127 773 261 2055 1395 1859 956 1801 2699 378 3104 3479 2491 2217 1731 3245 750 3055 846 1095 3340 3665 1932 1210 1700 1176 1627 139 2085 1669 3566 1154 1882 543 200 3287 2949 1852 597 313 3570 3481 120 1422 1480 1297 1647 1263 2159 3480 333 1447 2963 1672 2487 3459 3219 2800 3005 914 1953 984 1082 1892 1927 1399 847 1766 880 2880 1108 1900 1220 2903 465 2457 …
Output: 3473486

Example 2:

Input: 834 697777746 292118072 860647918 343364947 378375133 963937516 719549449 193667708 365808833 301087041 39651930 773240258 332398232 123725907 561927169 634015358 530336360 500762283 137362852 925902710 423794274 206494522 419569178 979868199 340520338 288276030 333115271 640924824 41366013 967731145 53756478 658088014 171386960 73111639 671608469 519164116 228968417 687354763 648443149 876826317 381905038 781682433 365921267 991863269 383892886 771644571 274374623 41570080 633329073 463908174 751630162 207967407 312753522 146901144 3625010 656301218 105144896 835336075 321201861 594843500 382780546 550892439 826734698 693202471 734965032 621035015 314216442 325497993 315627232 333994451 997528345 153145188 657007687 673734670 369000457 779653701 698095061 981936888 372242220 165628118 956…
Output: 175980

Example 3:

Input: 3736 152838819 543195698 868084634 200741137 538204560 414009657 52098788 711163372 447235444 322842056 534122209 470662000 98605033 523236023 707194074 779456920 728960520 756432064 650208972 377386033 890235005 222932046 826943048 504784419 670195207 399998463 284438392 322426370 807792901 271695113 730696971 29224168 176762535 961097464 824008155 182479815 869113858 235000748 526104090 30697726 836921507 10144194 48048278 484009880 401949724 229824314 404678056 614178157 969772496 378756410 131647966 208968890 865827299 789504543 730782537 28802859 175950452 272049015 113623826 421606271 882809782 261301514 66207422 230936177 141687179 132029410 768775712 22723443 878437469 116461195 546285302 104355733 268238438 993363882 115003687 380345725 386449870 71570041 498996564 770202724 79123…
Output: 3484924

Constraints:

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

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