CT64684

Cobbler's vials Disorder Count

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the anvil district of Hammerfall as Cobbler unrolls the day's manifest of vials. 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 <= 1637; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 969 862212431 221760210 694504853 778137406 791938088 992930231 250694549 637627779 283629383 571228881 687297574 81265893 696974536 677755341 636675681 686284816 669934948 676787234 451440556 470012302 569047700 478945324 981911563 150074329 327373437 576481025 821355700 658881934 928511561 852726849 284286613 46019221 342582642 24006758 115986633 218435293 552064948 852562288 952202057 985526801 525128153 863202598 45691038 180824962 134823559 69251644 67443877 753180121 771597037 705592708 489443197 22040046 4884621 875894188 607998993 5353629 69665708 172463956 719630134 790693776 400662703 90618456 766527553 745503458 749059056 457615854 333484724 130316420 442867919 379231229 453569976 662567353 560464017 415760542 242659815 92323577 373404706 624107634 97700332 182040712 75718253 16…
Output: 229783

Example 2:

Input: 403 932864327 896019289 930341961 957890976 421280796 555738537 51354793 152490837 58367743 381603011 321245447 602850533 360638276 112808754 460179715 443277062 69439493 359192889 627609920 78370027 643527084 214689170 737246524 893077661 240820907 704273666 14355129 184639798 149320145 890663778 108593274 796712389 960249951 336864032 584100977 403238360 973776036 314611235 176811975 301847978 93010033 95823808 352862225 521857390 642446038 187899066 681548855 346098535 126301378 876215160 816025041 969562983 683405887 113845377 211644804 89143499 879543035 71957834 720607357 592655108 189923477 152726037 905824408 415906124 735875255 428761374 882702063 19908923 516697044 653853534 311384868 544299294 583575793 68201146 585282746 350626290 146285033 579054272 649414742 675980951 8912179…
Output: 39940

Example 3:

Input: 1310 797743700 972817319 225645670 110899589 916522286 960699400 213580618 428875387 357793976 447780543 770770163 805031617 166321547 21062107 266153635 721284957 497581889 162904956 347790286 162806872 842556992 455160916 360112738 867265113 815834204 122994857 347857831 525842171 670484131 474146155 839906844 65406861 612222457 807278558 87044940 759088216 782684177 407911043 801240851 116097180 557427808 69134847 822991994 74242409 554879036 333727534 142134745 400051002 801510294 643145506 907097058 311350733 562179042 316566363 368575132 208118464 164479949 7727547 922721951 648358289 316988878 572744554 344136090 388141333 120202820 319101640 505636171 267461754 455748903 172313295 940343483 358523248 784035353 724165311 362008149 590946265 133332187 547744802 299019304 447982999 33…
Output: 422016

Constraints:

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

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