CT63155

The Disorder Count at Emberfall

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the port of Emberfall as Aria unrolls the day's manifest of registers. The tally will decide the next shipment. 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 <= 3351; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1564 114055966 282719891 724042304 467581465 267459238 656197759 514737020 804959579 170553939 661355756 977910076 83788570 918355194 920595714 843200155 106295015 739532927 978049388 33757202 878260413 918380639 101945504 368185608 213679861 782197076 875097147 693589667 829374801 974559737 36976645 950206297 770710816 632393968 993403157 918792270 568547656 313621698 180783518 824210446 756863055 633833169 245512240 692008750 414763918 519242940 257319623 877277715 451437534 13228479 211034582 528037881 960596403 844790422 432373364 578588975 440852224 945197758 751939259 445336418 38476530 791486986 866044563 456366990 442538529 931393652 38867065 401408550 114084024 714154029 430197031 48739218 830556898 962697565 820475970 581435279 826523350 82015095 519929947 301999008 65448465 3165…
Output: 631907

Example 2:

Input: 3230 731917469 396619634 795798309 885571725 459452779 945514752 919106448 607283628 594806100 462525000 352471080 467972773 959433081 894387600 136244170 943766862 772235082 550325304 9115607 580427123 128889517 423766200 687452432 27697646 110926099 23884411 608127843 860782483 70583646 429274109 516009604 779836918 809272028 308930053 108146337 105322163 93869887 777652888 41388083 350723304 127061542 727406826 827318677 9080730 914583915 651644272 661697903 305656260 879228417 863692143 749883614 873580568 543283407 469112348 267109834 790168445 717808170 645813909 806215545 33523383 74333250 423839547 708247506 110486809 236474069 79664083 227694306 145612972 193590238 776477592 133735297 697193198 696331177 446064845 635301845 175892910 590325682 10020308 7785373 969813592 395319713 …
Output: 2609663

Example 3:

Input: 1578 188084666 609240586 343748425 599471808 513589686 414988081 562863129 401374455 153219494 329338942 516420164 159754794 880861840 530540755 123359636 464580335 462246930 600014609 699946834 599002221 841107960 186130372 501761580 132857812 638499141 761085243 256261840 909071450 597735553 41450746 505693256 482030528 19534983 233313924 862380776 372905598 481760884 308757357 798839432 320113653 15832890 938897504 469664380 300946179 863271543 14859427 630432296 357947924 994074458 311491756 776136012 293348168 527731362 871666119 203581151 614656094 39107619 464559657 52515682 910065676 16263286 897657672 65023830 111751964 818024164 518204773 805206123 899698701 649245512 199628044 716735826 142700804 161392833 802634573 35690305 587227777 574391415 810995158 526580133 935422572 3825…
Output: 625397

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count at Emberfall - MEDIUM Coding Problem | CodeTikki