CT56831

The Marigold Row Disorder Count

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the saffron fields of Marigold Row; Minstrel weighs the day's weights 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 <= 2313; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 383 370760383 475066942 851522717 773251594 696684184 6340740 31973558 400734693 441601199 246376365 496102481 286963741 123669293 566348614 64667574 456583051 689152711 389587466 159205232 260963084 83256322 110839028 276014317 505250657 578595759 954632150 758861640 120688839 748873479 601567031 570494960 373322426 147712269 373850686 318133653 477928351 628155466 674069108 238562982 670389431 138412364 981551752 172788778 574540731 65750517 249646165 20996509 639661252 110217520 69623382 904248418 68518119 724006418 538718590 126627365 365606973 466010944 485213175 987964695 817336172 310328252 474628864 313331394 904640450 399226379 513669410 512062528 940943097 549251299 985280977 271579266 147240668 239858002 136402369 568617254 838540716 70310901 22282540 123398008 18578274 88830860…
Output: 36206

Example 2:

Input: 422 907758571 314311672 353326826 58538227 2648210 850453725 710352114 520911557 592232001 798438284 781773712 977496379 843634084 623209725 827429453 651683884 502882497 341832815 206975204 207922008 11900900 572334286 51605275 866994288 422600971 502284226 318994023 141603880 477367096 89880487 179513739 439190000 802863169 377375509 451578334 761062301 275665565 178902781 623561557 189921674 860544587 63327905 525819577 104034592 900092548 142944506 302233097 982796714 633677535 265907014 656553565 696313315 105522295 772115720 835479166 723692529 416941506 517790665 444755004 840122861 400103808 836213965 322344540 421485795 386635590 870963309 453126022 630251206 142292594 428896414 683520712 770753590 133665471 312967353 696260279 508371340 901677259 398940409 486801672 370250528 916…
Output: 45357

Example 3:

Input: 1239 663 276 546 509 685 832 797 585 88 909 17 835 1083 47 1139 994 108 1046 256 883 945 691 387 742 647 1118 14 215 152 846 649 780 817 1124 251 591 480 261 969 462 933 960 781 700 477 186 473 519 793 220 593 1181 1160 1013 995 612 249 447 9 414 463 997 741 347 1185 341 127 292 58 242 296 359 290 204 457 289 1097 7 200 266 172 733 955 150 1161 634 906 1004 569 1229 1086 287 458 468 439 349 782 912 791 445 565 837 1238 1134 670 601 1232 1039 669 317 613 725 1020 37 283 448 576 456 1201 329 588 621 188 759 610 267 268 664 638 724 1148 641 910 168 1156 274 626 1070 985 114 159 936 541 667 1006 829 314 0 1056 1093 646 198 362 918 559 223 325 698 153 195 368 529 482 916 568 892 474 694 598 180 3 82 385 956 465 608 128 49 581 978 873 653 1202 96 63 1063 5 181 652 77 1088 577 1224 1140 202 896 2…
Output: 379945

Constraints:

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

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