CT53591

Silver vials Disorder Count

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the cinnabar mines of Vermilion pays by the answer, and Tanner 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 <= 1159; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 629 468157744 771391355 847744127 815850103 637492476 532728220 715631186 939037626 198213462 446179347 965253993 457753922 811753422 724690201 245986625 933997128 49194641 931322233 87685317 750335518 556108496 369554347 807505509 338653976 662465233 487818791 408939332 361761410 590411950 583224038 791051050 216920528 351647263 130957553 995954131 435310253 970680730 519894329 194165386 617636693 361383444 225034353 585776768 526617663 551996155 554074459 364531248 216632590 545070832 714239958 344052977 170588975 132598455 428259427 233076293 822073369 351425762 680437846 225171767 502774632 140551815 139920809 140556955 858339572 899722636 149441913 608492940 591352858 969005281 346484182 458183050 885661160 467235648 976666668 299386324 528371258 740001873 171182721 500742431 96835743…
Output: 98234

Example 2:

Input: 802 676793047 51815494 965168243 242755884 117832138 193304381 519913295 87325338 380142798 386300655 748719704 273021214 445767864 802363797 487840606 23908183 858046319 930388210 159919186 99140370 855096561 528820872 392032528 489856867 50073068 155012250 599410757 676759824 71357306 388338898 397121664 199385418 351271963 446569402 282447025 487067953 931400255 877614456 650927878 924045906 822478852 230280764 245661345 192448807 60698830 337165366 651167672 561691941 312303064 424532248 159578349 706066978 128456459 332843026 815287583 963460888 838520898 571083684 500622132 445553926 882862970 254433239 517555592 811872065 676098558 952805318 266655780 551508847 255569514 593253852 18549596 493892517 742990171 94287317 223562762 459962747 579239122 906098684 423620332 958368851 62489…
Output: 156630

Example 3:

Input: 1002 978 271 967 9 735 551 179 943 18 425 660 105 396 556 470 575 144 323 287 713 265 243 278 513 788 874 507 202 987 971 256 381 327 672 885 364 478 400 156 883 952 705 704 980 850 657 512 293 686 436 900 316 542 226 910 528 502 794 642 882 161 861 283 290 624 715 203 460 356 884 177 613 191 947 680 94 951 320 63 573 566 417 946 64 393 463 841 645 322 995 984 435 473 439 740 570 745 414 515 462 331 329 878 807 644 23 997 186 480 720 957 299 51 91 993 769 592 52 611 246 486 65 526 242 869 229 449 133 610 892 468 764 748 199 155 236 410 272 639 709 53 445 710 162 557 986 107 195 677 753 527 223 747 196 432 136 823 476 783 843 360 595 253 345 402 234 938 262 617 72 391 78 314 863 776 334 899 679 693 369 13 41 675 508 69 121 733 95 61 123 870 92 211 976 803 779 1000 424 685 872 926 96 912 474…
Output: 254281

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Silver vials Disorder Count - MEDIUM Coding Problem | CodeTikki