CT64748

Curator's registers Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Before the gates of the bamboo terraces of Verdantstep close for winter, Curator must finish the registers ledger - one figure at a time. 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 <= 3394; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 1021 498807931 280579979 818899187 950713796 416504185 673298190 894509247 100668831 105227304 732299099 401290463 886544435 155613756 899376759 975759200 99820652 162613205 212705608 736987311 362032515 181888883 74682498 552171872 108667552 706401897 859773728 392106753 811399592 479041726 898853644 217657287 283285267 855218159 661040029 858056211 124561704 760430899 199506726 498050100 113699935 778049085 194087592 364187080 8765479 745316820 676567344 496588899 248700000 381765956 360273531 530024490 243623575 122022104 52958564 750220189 969834342 952696376 240333292 797227223 118249892 760641528 771919359 46012198 604949537 754072866 500501954 422257356 943850620 909423164 883352991 764102207 864900039 908281332 941124410 695293208 300112807 379466350 932968247 63463600 526716187 25…
Output: 259843

Example 2:

Input: 2924 998807124 606222344 246841522 141197198 473247723 714003317 172877062 390191685 292180617 940637756 473295124 497067899 418960085 526043539 633016440 425483445 333801337 136778045 483069129 124189087 86065776 985471273 176330122 914129870 619781660 131876260 18457110 470195492 403802046 644893798 291939626 361266286 867605876 281075038 18240378 629903244 451141913 899523349 552896452 157183730 896425548 896781762 766407803 334589960 766544873 144493349 265123470 511000553 342265199 649267022 58021501 948040869 36301392 530382397 96410087 18797107 226127508 135010685 439244087 952786915 501996419 915071866 977387408 716584676 46721508 594020592 289598773 487275391 720661339 575508392 261080420 3770664 752372873 805382661 809623696 661716953 855843036 211032417 282222064 926510470 46722…
Output: 2139133

Example 3:

Input: 3383 420 553 2319 3208 2641 2613 329 2685 2047 1719 589 1034 84 2689 3211 1349 2606 1243 24 1843 2585 1715 2118 2013 2691 2364 2442 3151 1322 118 889 1183 2476 2261 3225 1906 3238 186 2369 1475 2699 1728 514 1406 783 1044 264 70 801 2542 1065 2190 1985 3347 1086 2927 1840 1694 1905 1761 1559 1267 797 481 842 470 2815 356 3288 859 2496 3013 1339 872 1472 1637 2875 2125 3038 757 2709 180 2486 1387 222 1107 1550 1705 2016 2043 1792 1078 2879 2335 3237 1974 1052 1152 1136 1819 3185 132 2425 1486 998 3100 3372 2080 629 740 3169 899 830 1261 2266 921 1919 262 2371 3168 1404 1346 2493 2684 876 1986 1395 15 474 2249 1806 1410 2342 2167 2003 1017 2447 2870 2284 2340 3047 2082 288 1469 3184 1696 3296 2511 30 1488 2615 2793 489 2544 2768 624 2203 2376 1716 377 2966 1962 3257 1823 663 2081 2665 652 15…
Output: 2852067

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Curator's registers Reckoning - MEDIUM Coding Problem | CodeTikki