CT59300

Opal and the Ashen vials

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Caravans arrive at the quartz ridge of Glimmerfell with crates of vials, and Opal the auditor must account for every last one. 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 <= 3250; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 2578 696204360 51826551 837530932 83578152 612064322 438814431 439613408 754669501 546922144 342880737 989240669 947378595 784495374 959778611 102728506 827367228 541991535 761442486 962767683 376985082 936622340 827957798 332699512 942871738 855842644 462211466 810957687 13625719 51030231 583214722 861040123 792819941 652762933 280661277 987427063 189532015 912557148 791676233 367329466 57358505 763670964 632097953 916932892 703944969 764805466 706133448 682352025 661442356 221547813 259248878 747104811 774237285 410817828 963311289 450497460 193698270 467392450 648815128 37377983 16182139 22201754 394732969 306093203 394801124 461171516 984198273 710624456 48190535 140039196 177965441 257778035 210046240 597051199 512666204 140578745 247228926 494430094 143855770 272468005 182275039 6518…
Output: 1677500

Example 2:

Input: 141 161192525 959247170 768879078 782963303 31199333 228488952 903153243 894498020 240367852 729585788 407010633 887176446 54193600 980827374 828948405 618033012 498628837 873000586 572469383 177758990 128961553 514342055 122413188 7953523 982614222 878356143 98374026 402008031 231049459 512183901 805880481 492392621 651185067 282359168 240200355 734039863 32534126 825659663 880808390 287542224 884345961 704336871 483879720 276310334 104500295 130671811 784447656 109725793 335904115 513197924 669453318 21681300 689231430 310445744 938838079 507245825 551086953 102838704 652234482 358316826 945930421 16793460 748522349 881617150 430619514 525302742 916200495 205267587 254258631 543809020 57722669 418362443 958591929 471446592 847920166 614090203 539738490 705547520 601752565 481689721 54013…
Output: 5354

Example 3:

Input: 2791 322258147 450549758 125240298 480445808 280288375 816656536 924378533 26059141 277600160 287565830 626867737 180698506 977156562 739752077 919357773 128318294 850684610 655757576 857114687 836179848 406938262 387564037 422923429 853670294 509712718 906911343 128036827 125903603 899944955 507273637 687028073 411224221 874250202 393025529 827840963 207479193 943062279 919200133 383584454 630064051 78770784 686074031 829023127 290731878 168681210 515134617 218510626 529517029 300714883 540783938 308796240 126006451 857120356 960977869 983779485 263820071 129074316 347078653 626710603 179613304 427325530 457248984 735196911 279850406 946108583 412330920 712948411 422807257 372400863 313931910 483602465 121337613 452059620 685666548 840431041 937146224 544938387 3850791 543373191 693109531…
Output: 1956804

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Opal and the Ashen vials - MEDIUM Coding Problem | CodeTikki