CT42533

Sailor's Bronze Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the rookery of Crowhaven, someone must inspect the delivered goods. This year the task falls to Sailor, armed only with the crates register. 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 <= 1520; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 362 409543275 855923538 867140548 554793055 14117890 518147382 734528036 531967100 837816410 589297494 758188657 579519497 839240603 429307820 588141261 368284644 183063314 611790876 305560014 125602811 649952741 356433418 351994360 3273568 621695041 51112845 243482620 504536691 762292596 783397622 772177373 836180374 193055628 531937128 552085009 787875176 729903054 649281646 476733110 570443909 445270532 815038618 562992042 875241532 121345971 292635612 383255420 122805668 206829018 309535877 897211507 800539872 53298398 786203253 749194076 225467479 910396500 490049834 865522671 354095182 542222681 474851737 753815799 467013910 189037399 700722162 268050015 455277391 7867046 852317481 433905949 337638320 709316988 224338768 566584150 252377909 187774347 950136528 15867185 80248667 20586…
Output: 32994

Example 2:

Input: 715 221 413 110 450 230 214 168 710 100 21 614 90 206 67 39 665 291 253 259 339 568 201 142 590 231 285 440 33 272 542 501 148 304 318 514 629 294 261 448 452 255 480 40 550 369 157 20 290 447 512 72 167 404 340 560 276 637 108 458 75 334 664 218 43 633 292 77 618 496 116 86 66 205 270 79 586 98 310 204 387 469 226 182 494 188 403 582 653 234 381 684 2 26 470 638 130 170 216 521 190 373 220 122 685 189 65 212 109 250 580 106 308 468 273 420 562 121 683 245 531 248 363 376 36 505 707 576 330 115 701 589 490 706 87 156 627 693 233 435 438 388 351 433 425 554 491 405 200 336 173 659 0 462 179 410 158 181 561 224 146 136 56 368 538 183 678 694 691 713 371 479 12 474 596 8 558 187 559 631 651 46 62 454 102 375 284 510 569 137 55 265 209 539 296 154 232 492 151 228 150 195 315 159 662 564 598 32…
Output: 121715

Example 3:

Input: 1011 82 660 654 919 739 663 17 918 982 650 972 498 585 153 706 551 791 504 102 360 1007 515 959 46 219 386 1009 818 428 547 202 289 59 603 271 337 163 107 74 198 223 461 34 152 921 582 885 711 784 976 536 733 597 21 213 495 92 334 323 205 643 255 237 436 49 246 57 134 63 29 248 211 422 125 177 101 336 586 418 877 235 889 766 249 879 905 928 90 229 112 726 640 503 322 859 954 598 284 788 354 513 652 103 155 227 638 946 543 502 396 557 41 106 949 644 888 341 805 268 718 443 569 942 274 87 69 304 455 470 520 845 449 971 637 684 662 115 881 480 139 614 479 468 816 164 742 121 100 694 331 927 486 744 81 625 359 631 627 285 896 612 756 962 764 215 291 310 755 568 545 118 952 462 395 534 796 61 829 579 724 642 573 124 427 416 771 555 525 302 510 297 9 253 992 758 772 774 577 267 483 572 36 659 83…
Output: 250712

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sailor's Bronze Ledger - MEDIUM Coding Problem | CodeTikki