CT59880

The Disorder Count of Firefly Mere

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the lantern lake of Firefly Mere pays by the answer, and Silas intends to earn it. First: the full register of vials. 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 <= 2103; 0 <= a[i],x <= 1000000.

Example 1:

Input: 1361 57195 576116 482819 993867 466496 245106 274168 631897 200878 874062 391733 258909 702362 922939 698649 819491 179945 261859 93174 880643 725714 97929 637139 528011 660656 691449 53534 361247 816161 580710 976172 151190 829594 307682 279768 672890 913916 594388 153666 368420 67011 545569 272685 441842 937173 641419 780684 217619 358931 911289 814571 938464 620868 151112 947464 34753 722748 58061 937675 575540 529723 723779 527845 122910 955601 531935 97917 383686 102234 1179 362794 356945 221356 423797 905347 822962 900255 1954 949165 299671 930069 385861 972080 225851 749547 561248 600546 503835 750835 391802 220488 564242 135300 206755 898838 913578 431414 174040 901533 219308 769244 913475 355359 542258 963318 862769 576756 571397 362583 232504 618548 552114 588281 996458 699527 21…
Output: 470287

Example 2:

Input: 201 974843 737853 693922 768685 205521 727628 933484 672311 165957 385267 92593 863611 699665 619237 266665 433799 883185 162338 463612 661550 928223 106025 623684 512134 491726 41398 942641 150596 271889 787780 142573 426447 77011 3178 899084 917462 249798 649421 479799 210364 500107 663581 940199 824402 960357 677016 867312 396845 823447 26606 67131 133190 405382 754798 813553 93511 999465 206787 236119 201433 276907 788504 115952 812997 508920 843559 885373 250476 397640 540506 886177 900589 670054 442653 526010 403928 19626 575527 848156 458965 792456 917770 222893 39676 966873 802244 257026 30898 136588 140066 710783 934237 43746 767203 691461 802004 132800 405092 661100 746637 896269 608444 224932 846227 296437 640252 276763 457222 313600 26528 878074 368016 220369 122152 220423 4411…
Output: 10397

Example 3:

Input: 942 838 314 504 56 514 825 657 411 232 182 343 57 632 413 94 589 774 137 417 561 892 806 283 170 635 316 483 598 612 614 22 285 291 228 581 741 185 241 505 566 206 211 647 920 633 82 466 484 370 409 59 412 194 221 197 937 549 128 846 886 506 660 763 4 757 711 637 415 135 517 638 521 805 855 722 40 548 236 337 518 515 386 50 592 216 835 24 266 8 209 674 187 423 87 792 106 107 902 6 898 372 105 1 801 428 889 676 891 257 404 819 618 933 869 733 433 432 126 88 456 479 636 377 745 928 125 756 29 286 361 883 351 359 866 680 329 822 671 524 261 851 939 938 885 668 98 556 357 427 446 560 30 113 41 276 656 7 298 92 374 272 398 20 85 123 489 508 594 912 364 378 918 831 477 772 324 455 438 169 141 852 222 646 299 12 760 587 934 698 683 535 552 906 325 661 77 787 179 121 295 617 393 730 601 574 520 28…
Output: 217425

Constraints:

1 <= n <= 2103; 0 <= a[i],x <= 1000000.

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