CT43920

Saffron ledgers Disorder Count

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The measurer Cobbler has been asked to publish the quarterly findings. On the desk lies a long table of ledgers readings. 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 <= 3022; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 793 -449091 506329 -53934 -61283 423965 734268 636669 -324936 -676168 119068 783514 -807842 -201724 750973 290583 754714 801806 969712 -890285 -912799 -834840 -301418 114468 -689001 729147 -703596 448148 -11940 525415 -670953 224118 635750 -248409 401515 32738 -36786 -553526 630055 207001 -721091 74663 677953 829786 3119 -488999 979076 -356483 904720 357134 907010 226048 -793376 -387280 850592 -136698 493106 -526166 382403 -131923 -249717 343266 973234 371183 231415 978235 -345293 -728939 -423649 -206692 -55665 -266451 -388739 -473452 -857757 671362 -997650 -722257 -547760 288456 46681 195737 696642 -306280 745672 970937 -345497 658850 -484336 -481570 -349960 -927595 -474507 894009 488425 810453 434325 -728086 974615 506216 -640789 -68426 306230 -257602 402587 483482 -196326 -305570 705967…
Output: 163733

Example 2:

Input: 2321 797132 368314 -689332 -928742 596311 -717464 459998 -756544 107126 679040 -588393 569239 266001 -96948 201477 571831 -328362 -243230 766761 376 506476 53643 869790 -367931 -703152 553627 261228 357744 80930 525868 796379 -494965 175239 632897 690212 804911 217345 775290 712182 -868748 -312155 438370 260078 -713449 967714 268728 -72203 479517 783872 542217 -783330 187126 33033 65958 -490021 921396 -450423 180168 966441 307138 -949599 524735 -388104 129266 599104 -675533 38455 482149 -221706 -510040 -904379 -709135 -70526 591265 -160531 -755529 683498 793649 300474 126439 871640 688785 969056 870963 1522 208524 291418 138007 112048 714375 420507 683313 -723961 -544414 -124718 -655552 -349503 262294 377767 -796422 -209858 -558152 -880722 -355508 541964 692779 -20366 -349185 -405200 -9367…
Output: 1368888

Example 3:

Input: 2409 -566892 66970 600670 -715482 -970042 619604 -669802 -792371 -161798 -961804 -478446 182370 192704 -39273 103418 234148 -279301 -65097 -735591 -169460 -256854 557619 287826 719396 -422728 -530060 896071 -264535 -981958 378513 970628 -810628 834900 589922 816676 763402 -288140 -536507 746918 969613 90460 -384361 219696 -602271 770175 473776 -526832 764129 851051 76232 641932 -160564 -756407 -424768 763438 314352 -199200 981238 953599 -738166 123835 235573 -941669 -740514 243093 327786 -804268 159150 400288 15695 -979013 -662468 554230 903994 -329627 21207 -880830 75273 767784 -696285 -375649 45840 -285924 -931930 827058 -559591 79163 326309 -502378 253124 878465 602027 -627650 -355069 616133 97222 -479025 370041 -65305 644012 219147 -270869 -880445 -160242 737700 -913222 348502 301142 7…
Output: 1440238

Constraints:

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

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