CT59877

The Disorder Count of Luminar

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Legend says the vault under the crystal caves of Luminar opens only for a perfect tally of vials. Darian means to find out. 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 <= 1399; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 149 843802439 97955653 72050310 882791756 488530495 50377533 378883651 781199124 880236536 999693570 928583544 71601705 716253909 159342296 973541920 390585778 441851201 517683020 715429712 805352653 724579241 435856082 524337330 350034676 713595489 921362880 986132146 248285665 215841035 834597458 823641187 69790025 469741324 668947914 454188707 228836990 245047097 972864856 286332458 52384406 63387229 145660663 588589483 145628651 674510056 587461311 84820732 335797355 449435155 630758598 415906495 73547479 678513731 250584208 214185473 260058501 897364181 796566390 192126247 563455209 954497494 592363077 521959063 685055007 638824836 444650366 850924411 189827301 569436972 934582180 681826047 664196597 659766444 34503491 808511416 14971616 271523940 263219474 963075679 906989610 1868616…
Output: 5642

Example 2:

Input: 1183 988743850 232792949 371325459 412879822 617456419 107969300 78038803 495923454 936725161 248555191 340485542 517284672 343401079 16023606 421650267 597573071 851264002 483834020 364895259 976424205 583961213 899800230 737411445 744947232 849963092 99962465 897182308 646774506 445778431 493997928 877172350 644542606 963283152 446592965 992012997 454899881 88499604 445162728 709447619 265098433 897979796 571119638 952246190 475683870 643388135 914950235 509419988 271222313 457822955 807170945 119684270 453898350 478423004 36014156 468599205 259656184 377591186 56945892 130309414 282527685 63785828 295290914 414520633 244580547 471451728 992466265 251403690 462843051 753284526 70117912 831475875 321050325 452599190 141073116 847058332 229249793 151166486 98041287 696395959 339198892 5985…
Output: 353269

Example 3:

Input: 1217 670746677 68675855 726087194 518575200 211682159 324769920 392585519 903114986 971889454 95314322 170649047 679643850 644535263 393126249 31551088 279728321 156293099 981342102 250788903 755971981 486232865 12022907 21436825 418983329 931213698 201676042 3786248 215987069 273398966 322796500 888784391 275639646 715476635 95454206 96267407 957522943 397144861 119715964 499931534 891445310 185653197 447733499 503019640 118441 49539051 315914213 284937270 416838450 421453293 747649089 861108836 439910894 788632896 998169767 91749739 157827328 384708103 61279435 756813779 978096468 674945450 316023025 999631400 492903526 811527086 277315347 812784911 549553321 61435825 286881893 954254341 493717699 839251371 464596713 187662143 329171272 100765043 895421371 397962666 405900713 543998789 3…
Output: 375795

Constraints:

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

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