CT60774

Pia Counts the weights

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the floating docks of Skyharbor pays by the answer, and Pia intends to earn it. First: the full register of weights. 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 <= 3924; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1172 417164928 979306842 137009261 954457506 796186153 557470768 847882654 919088739 781780966 661594600 903473768 57219798 965019483 553065852 672357123 346168685 803055176 689313235 59519282 157803299 667670728 913697358 61301183 985210791 233049524 505043678 690501113 930607456 980751590 219731920 260609978 944890635 608876127 572411218 407154764 38170403 353305820 803412570 871007216 637684010 111550188 191130324 879332303 12358623 696053296 131857036 39918648 800765131 81374841 228688029 837058995 105443353 857653362 323547816 122459173 532419187 327286640 557185640 846598638 318357344 402846875 337965572 320969929 879912025 19076344 337593819 76853016 359057052 967197931 175633971 773860118 401784662 453989392 166804491 766297318 606304462 716018038 511177084 122737043 309923822 9173…
Output: 340686

Example 2:

Input: 1748 738088131 660405738 477543478 624882102 239413440 81852225 823196495 82613843 21205635 439932587 311041075 562101562 689598457 566035073 429004371 840588890 943177095 866737763 79092760 634504450 553346174 508715947 800769519 689167792 673718822 36209888 782370959 294092664 73929843 156806716 144066268 978341957 379915126 298063191 303734682 280014214 979043543 120810017 968079296 185284226 451133727 756975810 678768398 224066422 509191538 455115845 665747628 260616605 265382161 412888390 105426029 691126119 144934443 464442924 398495296 378043821 546152709 905497240 888732353 894761004 720398480 659576148 329841161 331208848 53288057 791044838 66627538 34369328 534346299 291027469 305217033 413932993 530297243 945289851 322516144 739764520 590342347 797824453 488178081 336536617 7575…
Output: 738945

Example 3:

Input: 878 195 501 166 486 410 658 163 477 174 515 156 806 252 328 667 62 656 810 248 388 371 278 401 422 765 524 691 239 803 22 430 395 785 644 554 103 833 46 360 0 295 300 687 695 697 157 113 458 346 639 860 44 437 761 873 428 712 173 32 350 762 70 777 112 149 7 797 344 254 729 622 288 86 259 57 830 791 438 124 855 332 374 25 411 224 629 336 9 668 780 243 317 613 51 191 736 418 853 752 663 794 747 707 215 681 398 591 142 643 493 145 123 514 612 831 760 58 271 140 30 480 12 97 454 115 560 703 492 93 573 415 380 94 185 862 218 442 744 452 708 150 368 655 446 279 225 366 232 819 838 78 871 472 820 653 781 333 491 151 186 257 131 580 73 714 359 852 133 672 564 597 776 755 645 160 790 875 105 798 731 5 251 40 80 784 228 746 749 314 201 513 594 508 507 33 516 153 79 235 827 426 815 722 637 872 750 28…
Output: 191474

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Pia Counts the weights - MEDIUM Coding Problem | CodeTikki