CT63700

The Disorder Count of the Bright registers

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the fjord village of Deepwater; Pia weighs the day's registers manifests and starts the calculations. 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 <= 3423; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1452 437514522 276387878 6440930 134130489 65735319 363207359 116250040 331235488 114489353 579721368 887960453 750397824 946999056 991693292 781306771 625334847 403081421 367965726 465522710 48893281 859223118 122404410 346802739 230803074 177337097 652443226 454751578 413009918 22912405 231847648 596411746 303041183 167229610 659221238 157223815 564966449 775517197 195504205 258135112 925558867 269416443 22352682 978715182 73204301 322818151 538689069 153055111 187015461 577091691 544206401 126177538 517132564 267426097 702561244 854190762 555080626 11235471 210903585 685551160 188039487 738373420 166208454 185008420 19266778 15378411 21408404 545204877 494419177 56410180 11909997 28000950 556474047 102446089 30708808 779191165 275121960 730206470 764754719 557398969 961105834 198832490 …
Output: 521456

Example 2:

Input: 2680 844097841 828600219 361460618 32028163 799116327 681012443 21953990 775545531 472722322 775957286 306334815 368942141 935679098 667872574 409037398 511235211 993893886 169219975 399517132 895746888 269089315 515343978 423527064 277497826 886445520 331807564 256749062 272462107 493546063 453395702 338734005 301012160 220048255 242390234 707481580 59835049 134278442 11113887 168827511 250368174 397585684 573377440 907964365 705282294 803463116 989447813 740907530 358073180 336754691 655037248 345357856 516568529 399247596 484049732 93080028 766290485 99439281 79296321 408896446 276810444 780099440 658132930 296629211 544214056 169026012 659989597 704731105 767207890 525115432 545137010 643241943 112933208 58920334 630137466 932502586 741935608 78023332 156536311 267920843 639239206 6856…
Output: 1802399

Example 3:

Input: 1648 1138 34 229 416 1601 208 1324 415 1017 910 1256 299 1166 984 726 1357 974 1479 669 949 1314 1144 216 1118 390 1301 835 473 1535 1231 914 551 1331 1047 953 1286 253 1272 689 50 92 889 1424 483 203 1613 526 1048 1280 1232 898 1171 230 1550 630 608 790 1202 1065 1086 1168 119 1362 755 1061 1447 1178 489 88 1222 1172 235 1273 1079 510 1363 193 367 1031 858 220 778 452 1195 1024 823 985 723 248 211 1161 1556 451 1269 761 488 215 1094 1296 1224 168 231 711 1003 1268 144 924 1529 721 187 1329 624 594 1236 1477 1617 770 962 1097 1216 472 700 8 298 1544 464 527 161 941 1043 1039 963 1252 236 497 1436 1011 1539 209 403 734 1014 487 654 1186 1431 598 788 625 54 480 1010 243 154 1298 331 633 701 697 1068 1563 1465 544 400 931 1164 1359 1247 1572 945 1413 27 525 1428 212 1351 408 180 205 1170 125 …
Output: 674219

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count of the Bright registers - MEDIUM Coding Problem | CodeTikki