CT42510

Hugo's registers Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the tundra station of Whitesnow pays by the answer, and Hugo intends to earn it. First: the full register of registers. 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 <= 2812; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 1538 830 1353 465 514 620 1179 1283 332 54 158 406 18 457 461 214 1214 228 717 355 606 1246 987 321 955 146 813 1204 467 236 1409 473 220 1354 1190 586 181 1463 581 289 824 285 1022 1398 678 910 423 1323 418 479 1170 1 1524 944 1120 1425 1159 477 1023 1244 700 202 1468 818 310 65 726 1391 1098 574 1399 687 964 1054 460 794 471 486 125 1483 674 1234 1496 692 1400 974 283 773 569 52 788 1196 487 937 1145 94 369 648 428 607 810 693 1309 8 161 445 751 1217 893 708 391 1385 651 1171 1311 1269 749 1013 891 817 610 46 1403 1038 916 290 435 905 357 368 1187 889 113 499 615 1146 1288 527 132 16 1378 613 612 1454 507 207 1289 1424 408 947 80 1129 993 1470 284 1310 1230 1049 542 44 131 22 903 605 75 958 1163 1208 1254 439 364 779 660 206 719 883 1128 1437 485 983 1534 173 159 761 769 1356 939 249 152…
Output: 604279

Example 2:

Input: 2474 156837916 900960624 678915803 270221628 482831808 302223033 474594795 855764366 590789777 343901076 744433911 5609662 657312607 131809636 123827945 222184681 233704084 40354127 804365862 302769063 549925045 847704428 158510041 894364552 586774089 650171040 898192504 43201299 378666437 475011241 272767857 769391018 46853189 693615412 453048950 748258825 588563075 787355949 793944402 596249192 692255365 219107160 779114044 113510604 622843029 997505456 101285481 489527004 683374044 290728751 632022065 568618547 985107170 657889956 621011837 571287074 629691378 871383735 628965927 282995585 883766530 704891350 650027364 830673515 646924115 359825687 852851235 455465055 348868987 550574052 158946694 895066051 971823392 396473376 655486935 219230958 867915360 228625057 334143604 406221816 …
Output: 1543166

Example 3:

Input: 1471 294224716 705449658 292518183 624838832 350004940 199234368 403688190 245322754 386200074 956722233 456033975 559491213 355077825 905756423 603491212 941411257 590175572 884683400 551631558 754920891 146479540 4571760 407572227 386760726 395474334 138171202 421368079 392146053 845018962 79076354 839544726 249335170 79131894 772801180 173772439 761081960 527707611 503337758 527361249 378392084 74378746 662017765 375424032 645578971 183763569 959139739 521294757 214854719 323766988 208579831 410874914 978298085 352090514 512050359 334421626 634283825 845211897 213265104 268155662 400707542 339889031 756941034 219685253 393594260 554559067 562681181 275564514 320231881 558065047 545917909 866030343 271526331 287074192 132537243 350520224 227127971 677336879 208211633 689456221 384621242 …
Output: 544216

Constraints:

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

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