CT57796

The Dusky Disorder Count

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the glass towers of Prismhaven. Arjun spreads the weights 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 <= 3153; 0 <= a[i],x <= 1000000.

Example 1:

Input: 625 990751 432922 963892 834467 188442 181540 260759 863769 780592 533490 802199 633749 767195 122505 43231 521311 298249 726228 857044 993778 425786 239077 986574 609473 913262 771607 241319 376281 786089 196229 371645 123203 614387 312548 377499 68072 274981 301041 617438 835001 60836 274754 652481 686014 217 337217 281365 595340 775215 511909 413417 850260 144433 517944 239545 784963 65302 273744 643309 931343 136656 313125 499216 279442 27405 210776 687578 142975 826390 220956 875295 227539 35811 263201 33779 185954 642721 756651 438328 251631 53618 994789 523149 286352 836922 689560 173111 726104 85270 258348 963037 62864 704021 958098 823185 771658 352545 24724 719443 927399 770748 281948 607033 379960 930805 541950 72824 330097 483651 293861 98549 102890 94611 87620 41826 299441 823…
Output: 94079

Example 2:

Input: 602 145637 227526 167504 386928 996193 837223 65490 501855 133331 575062 242324 383711 707738 209247 975582 408414 610493 260761 122244 131976 330825 96050 363550 309521 468213 680272 87344 203724 69051 429344 904452 807213 912923 849997 586828 759965 592967 21590 833300 84978 783094 277789 849203 181315 451747 317883 421897 111802 676964 915883 738707 74275 470060 760590 134990 849493 131495 736225 578117 13325 634126 238107 320912 144338 925509 811843 897287 76016 91819 982300 528813 624651 87360 421908 331618 417907 234751 364301 19866 515962 31429 474720 914635 528593 327101 688702 6719 728204 61913 875302 978559 968157 904394 384356 877930 99980 750154 5418 463548 370850 558047 547197 266505 451243 383489 649964 855175 979336 87574 476817 437281 820376 202615 182594 766276 283938 1266…
Output: 87085

Example 3:

Input: 2541 1860 466 749 799 2119 643 1519 29 1844 1169 2294 779 131 1051 2498 1228 1865 1486 1689 1283 647 2236 316 436 1732 1116 207 2211 1374 1396 400 1686 337 874 2315 1450 2521 534 349 506 305 700 329 1694 2082 678 646 1014 758 1759 630 455 1701 391 926 715 1294 1318 2075 735 1006 568 1093 1041 2475 1410 2510 288 1898 1644 652 1841 1286 2037 741 963 1178 2047 2066 1540 2354 1678 1558 2268 1572 76 1526 933 281 222 72 2171 1973 1365 1042 27 1669 572 1039 1246 202 1933 1787 315 1731 803 2323 706 1287 210 834 492 1026 1128 1415 289 1388 69 1683 1711 2210 2073 1685 309 115 875 2339 806 1831 1785 159 1576 2447 1087 1488 1303 2301 2045 672 1211 1511 634 1115 1400 1037 919 2133 979 661 2533 1836 1422 361 861 1424 508 762 1804 1441 2244 1964 872 2235 575 144 988 320 1192 106 946 1842 2459 1876 1282 2…
Output: 1560546

Constraints:

1 <= n <= 3153; 0 <= a[i],x <= 1000000.

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