CT45657

Nico's Disorder Count Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the pearl fisheries of Nacre Bay. Nico spreads the registers records across the table and picks up a sharp pencil. 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 <= 3132; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 840 536 228 535 448 264 776 597 271 794 769 1 587 370 107 287 806 322 232 514 166 138 94 723 475 766 648 520 245 104 73 472 451 259 115 195 721 56 482 332 143 360 112 450 580 583 663 589 179 343 253 300 140 507 366 327 486 618 399 260 270 134 364 352 57 615 212 764 218 689 463 149 201 509 826 382 517 240 135 668 707 477 155 534 22 562 342 543 481 19 600 688 168 601 102 627 266 296 204 799 400 676 51 430 441 626 762 306 111 325 68 317 427 620 101 637 703 315 413 7 693 125 290 109 499 435 223 489 61 594 702 335 554 605 449 490 151 209 461 262 747 670 313 657 712 599 226 503 470 393 6 438 611 595 838 390 9 371 516 416 249 761 623 267 42 636 215 818 418 411 386 792 312 398 113 353 58 641 824 244 163 372 272 23 730 757 269 711 392 811 261 553 746 525 801 780 10 800 93 230 144 833 421 289 478 50…
Output: 176592

Example 2:

Input: 871 582 305 729 15 216 439 798 316 22 680 720 776 110 759 490 160 553 704 549 51 401 688 579 148 599 228 849 806 161 644 813 793 503 232 176 397 275 859 837 677 552 406 768 638 516 690 245 203 842 33 708 745 243 6 545 2 150 72 363 247 213 473 577 862 733 587 327 742 648 402 143 791 411 847 181 678 407 801 854 446 800 652 501 624 810 614 568 830 61 541 533 418 152 343 870 747 522 670 746 546 157 709 668 425 195 719 475 744 715 869 544 365 90 361 465 865 675 713 207 500 126 285 561 141 635 495 827 273 289 781 657 323 360 53 201 264 156 470 663 823 685 34 763 789 850 740 420 828 711 62 13 208 860 359 604 27 838 825 339 523 416 42 601 817 334 442 826 139 586 567 815 462 701 123 857 362 661 262 802 581 354 125 183 615 111 459 710 31 338 301 296 751 87 306 774 278 230 809 194 519 392 645 752 431…
Output: 203437

Example 3:

Input: 2178 698942058 341348892 944685430 738346822 752373044 318145430 135188266 919695374 935861804 7801592 833266086 21678228 433512737 12957234 500072185 358277236 682291884 41642554 45242058 354642253 534395217 213719174 96230266 375750627 706753949 629226320 950303335 770722365 50797725 43259551 311915129 831503261 158904800 330327381 708367697 222707863 779013855 182733226 663753373 909888751 417444220 433779553 112806062 349546272 381026079 768868495 513435463 544980551 612128762 430900191 777685076 436128945 634897610 749850254 572023891 218659309 475656441 510084865 318131941 838539600 925439742 560877819 793169527 826630493 364978306 170432717 187966315 957526139 197267852 163989546 410124478 142600425 369640047 865017831 847027586 392080659 500504165 216414376 34067443 929089115 12691…
Output: 1181104

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nico's Disorder Count Ledger - MEDIUM Coding Problem | CodeTikki