CT50679

The Disorder Count Beneath Luminar

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the crystal caves of Luminar, Hans studies rows of crates 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 <= 3328; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 413 721755861 876748494 288188111 975243806 56534005 716258527 267190966 724304484 73219345 151671377 824940103 174080250 260442894 220080275 52561068 222633691 991631771 206044904 473728499 404048813 312656726 387406170 678114535 97475720 709647062 758181551 772130167 745726970 782899065 641846767 50324729 74942386 848460597 743521933 989940033 581071688 330307513 382686943 140573759 802157593 917702353 848589472 847696620 2023420 141789121 740905052 772624222 675052312 271852274 90207357 678041864 687181649 23596752 185630358 854554144 674825160 458290914 582270917 568894528 591688742 537083106 728110275 459826838 943363531 449173036 682382515 283382662 585562705 295798512 833928567 82019677 48964158 639446836 483345910 269571225 783931731 427578932 468699659 865734613 169916234 95735182…
Output: 42201

Example 2:

Input: 3250 258721721 155772315 88754869 107764983 205016912 254089601 196169763 133491473 884389054 488790229 931646763 822269161 397495664 75216546 459590028 252955585 806367453 765258672 166429333 252483837 901515991 917313461 254066276 38936466 928464293 560739873 140412531 271183953 472937882 932939639 750615242 227349226 183857379 92719528 9614907 734574089 887079390 -677699 474761790 253142661 523319256 148353913 53396985 879833691 386935090 759239230 252876770 25858661 125405538 374498326 585875251 48647362 418413562 584716083 407549980 22553376 507387515 708061401 725099859 992416039 394341566 206099965 7825400 496807199 213024113 621364419 436037382 166603782 278625633 350169839 285711034 567192936 765915632 991560607 578357105 219956374 529553113 849653930 253967328 795026514 718009903…
Output: 2598313

Example 3:

Input: 2026 599567630 168849406 243837322 840767576 209219289 43519596 361546312 74138237 727354319 484198263 138867163 304844889 700226736 230749383 250097594 705612251 543370873 183482977 797662557 836373233 113089596 980442819 899100291 717481788 576262277 448507006 486589639 988992466 521297261 179868567 959678027 278397002 22726684 928208781 603501511 521222068 349246040 919361453 922970348 161829607 14876920 615523329 436289415 529548008 283328954 171917427 634944069 959432221 509130389 742692806 435898041 56694216 593853561 524155765 284031982 241593152 329201778 876681607 815957080 57080246 552827559 610759913 991518465 894431902 833596723 548490655 879828550 200316107 822003509 599209929 796680448 178546870 270697921 416149198 548434479 858798474 358037315 995061243 738007046 794428468 7…
Output: 1048324

Constraints:

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

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