CT43343

Peculiar ledgers Disorder Count

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the lotus ponds of Tranquil Basin close for winter, Varun must finish the ledgers ledger - one figure at a time. 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 <= 3260; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 2289 516687681 994224506 426891011 876265960 890799420 473866432 41041591 872523241 731564522 610071883 678637163 526956173 160660129 88232091 196264744 604838516 712721712 832895495 70622737 203184256 569602784 354485267 937949862 368703063 150220816 681956103 756537306 76405925 107731285 193199878 849264233 960699929 506083851 585537050 647130292 628133856 904238750 900790091 987202493 401944691 263131598 932627628 340858739 259622127 234453121 872930436 1135054 679555595 545335517 441346720 461515813 777846427 414907592 602713990 209118881 170284515 947936124 43327031 467452683 48755153 882625263 265096082 31557697 46639710 808801534 279483015 915504129 753644693 725347976 28189116 409076794 766867441 854316185 91549826 10333842 688047690 365864171 99686616 531343760 465891019 368645714…
Output: 1278028

Example 2:

Input: 1567 310804997 90176523 729729720 559988912 516877163 98590316 285863993 345050935 300813443 405148178 107150527 645584753 841061753 662796646 900667374 960858131 139367453 904068259 106976172 8589676 926497093 649885424 606619980 255849525 366242356 63621393 814213369 658068806 8735416 296978987 731527140 472521795 660539299 261390111 442629375 583533505 907139024 525011414 658167328 916227465 655729604 867366378 27644252 618579797 658096459 369523260 50216787 309463973 215976708 980598933 24752087 404194809 122637461 786160897 778145073 519479211 586163249 277913079 553394555 272782121 747584765 906242013 944829011 790147199 844169956 841204619 394011499 56057378 973761663 128684231 307132467 737637338 915840009 894718620 330199935 474773937 742050608 668733670 807613319 747770772 993932…
Output: 609969

Example 3:

Input: 2276 945265993 849232794 302031434 785491365 880865407 16567619 543671776 30366026 312234335 458757045 983813152 263371477 873654115 814526835 94653479 172428115 698623757 176903325 94203562 185551837 678934196 829018280 273367455 439676070 379326348 594710929 959335105 354716267 287568700 955112104 161075078 272183306 320749385 750897792 119564669 236512860 961789093 404271762 208884551 838691566 181967209 856384180 909527454 667780023 671602642 891343187 917589628 517984883 417760114 628928180 161698198 795151697 307199301 215445102 854624594 623403691 319548302 496438738 416659002 177714168 858176539 931576635 279307385 311703529 291470999 703759929 379541139 449108011 611180157 339678677 989695679 278052851 324345057 553829598 810988182 875799834 669973527 531128433 81898547 943540154 …
Output: 1302520

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Peculiar ledgers Disorder Count - MEDIUM Coding Problem | CodeTikki