CT55628

Isha's Ledger of registers

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The factor Isha has been asked to assign crews to the morning shifts. On the desk lies a long table of registers readings. 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 <= 2307; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 2145 235818110 426549320 346938087 248329784 737498365 875381854 90239857 137291414 430389668 489627722 734213027 820162293 501404401 754958977 193914696 309554347 347916578 983056274 127235070 45115072 181706815 100702036 694765475 320600405 752164993 731544495 322178523 70287330 724737642 415090924 451896938 776162085 806270503 231227915 749175452 441532782 117626846 883380602 8365199 343610150 633107126 229308816 765614952 512818337 910818952 242630453 73686079 771443779 148897478 3008783 461592071 143413352 134860934 746054461 544993595 349961254 232022146 499805334 668933159 990444431 696799207 880959309 44105221 148500878 187870478 44591514 103300132 163726658 603569489 315550349 60799176 812986246 398262312 282483258 489614608 640355589 997998316 925328580 172431492 229187098 185640…
Output: 1144852

Example 2:

Input: 1438 815073932 471821473 287593974 849164097 82663126 522403099 718094958 535058250 1990901 653084391 643361959 570140816 254614640 342354664 750610607 950730884 326898874 730528308 340725346 382584584 654612352 282739967 21734576 654156140 707449930 404820881 447858705 922318371 48889242 597815057 661762120 352658382 850137342 275817788 363123061 128304618 661001455 311486927 50094653 59440598 332342930 860877080 159255703 690713451 373658617 742818961 465868303 585681128 273083876 636780985 104322382 677972928 886672035 487927631 836620546 451212026 84997867 527300286 986168311 698530092 918171155 343679607 317599648 555155732 525015600 37985494 226306358 151325468 171564647 622035806 105780896 921692338 505283589 839121699 65001770 521723741 457888443 255378013 24756985 81648850 2778811…
Output: 512160

Example 3:

Input: 955 413350477 348100759 842796925 981713092 702976123 232289953 623896337 19459530 314971040 536440416 117192259 900294348 437291816 930145522 711478562 260506597 822695156 281165601 257728961 560224703 774715935 399280290 130312991 32042731 64127950 600361605 231606259 460839876 996620354 521134664 45656279 813349026 31671316 939295345 241254090 82493813 534150013 357304035 569883840 71245120 572994426 626156040 45350625 96987411 482548199 38513428 977261081 66321113 701165638 111015966 366987944 555287231 478833450 166178887 683814739 810238545 261835927 897292595 253992704 50761859 515608567 960208290 221252188 681925496 720112591 140385928 54430412 43673355 735042554 588651394 280044724 723222792 312411143 179344156 390374960 674389908 868390494 745107698 717261081 337952954 969368757 …
Output: 229865

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.