CT54935

The Disorder Count Beneath Bloomglass

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the orchid house of Bloomglass with crates of registers, and Xanthe the quartermaster must account for every last one. 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 <= 1483; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 774 843401742 785314103 783840502 113382439 695816539 240168613 559051163 28107702 743455622 646296297 161756019 344602507 956704927 8641399 707043494 176880561 204968600 191825640 918853685 158822951 991721536 62674424 675898921 826407449 391555529 424208817 276639601 336596300 896519319 631026071 561901923 435389175 118603621 489434880 787630483 577303713 103634089 462869238 23718632 126268639 793180809 471744771 605435491 357060551 627955590 319560395 44405252 51300358 368431804 394166176 123245654 559604166 528176026 379975868 866707443 568181007 746337117 844314655 814445186 889824180 880465821 912219015 802504262 280512104 627376173 79177513 650939 664838889 554904862 945693386 84415671 148253584 475366647 770887936 787638921 471232284 960213101 116197648 759263084 238676859 51714851…
Output: 152111

Example 2:

Input: 412 759899766 174589911 509354356 187662158 276314148 755966297 490217633 369673254 479133294 683563500 806567932 469479647 967105937 5624181 191632517 352878861 729856571 593382968 435068967 512454844 410781492 661679357 254932188 77745940 646881892 886670213 245118937 46196980 877405854 345579227 955934410 733347174 638229991 945079976 465072916 31630325 856518896 780768080 885193673 332939491 929936909 597153804 300680108 672186344 530356110 121774967 596831239 457651646 270647388 635696378 174296550 980911470 146986055 491761793 614292491 666448567 849417382 290625550 631421567 205022044 561852304 948994953 81704972 750622890 678947329 210433225 92532074 143663787 87135018 64533038 906773096 720379220 778598513 785517177 329275325 828567438 58503497 695531628 851720183 399491385 317938…
Output: 42567

Example 3:

Input: 519 818112673 679821677 404695868 36931314 29184576 601049181 778106311 568695097 343443653 134986572 59778038 54815340 240781732 717317632 963063992 340390127 34729275 959832565 679719418 168147047 375025447 980999609 917543600 388001950 453449111 88433796 893782090 63573426 86672426 325138239 277148383 327381536 952941597 879346385 393989313 923658863 383938415 303013627 926645009 139397507 664996107 46946760 418805611 973347820 717397814 862354992 320734343 807756633 339749242 456623250 598870820 337343643 197749301 774680880 663180916 793290557 203560282 559757693 4273403 21294131 506105483 677156940 712964651 418367360 226750718 670359531 131202993 453264952 827423804 320782830 762276808 874927634 707726821 427350285 317350572 185865550 123593210 345591336 201928808 517676339 68544237…
Output: 68554

Constraints:

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

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