CT59900

The Disorder Count of the Verdant weights

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The ledger master Quin has been asked to map a faster supply route. On the desk lies a long table of weights 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 <= 1851; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 790 809839879 225284777 299226745 335414917 81457846 881649732 940270046 473751160 212577746 879515116 629489038 64878173 76983125 873942026 725919691 803440375 790537124 121746982 376370762 319133332 311268189 472647841 340066951 410919502 327720850 862982722 136853535 678935186 350326392 917840773 724458066 272090479 39803655 534996327 562889529 728450315 552507117 681472076 203019440 182354947 404742555 51759567 467057075 538682262 890424486 716994369 668351561 718463850 399534568 29584368 419684100 334424252 159098330 836353829 849993406 541780369 886061102 183117 849845424 922203096 799653272 123419164 141607332 543111560 763836139 479141172 773311188 960761996 161497290 352820923 62149499 63155937 338264769 806624800 470010807 10429049 477397525 771631451 297386226 183972424 63981225…
Output: 155556

Example 2:

Input: 1609 107066742 222641881 526142254 942246365 58957417 152243593 524678669 887047543 393635018 847980398 693363736 526223016 101499396 208389594 338580969 762040262 141242950 246742038 395234146 805584169 211979212 323236846 51602480 133064671 866206999 239170143 18394345 22034748 510046044 809308493 70787413 760462613 186728000 920435944 53857698 604655317 918294229 394593536 215361334 97297264 729319144 644142721 67712752 366443996 246983090 127431989 531729166 296596913 373538229 378398547 326172573 507524711 986542306 424478659 187496694 456602561 534870423 464379032 602396947 55573562 901032488 180061541 122959827 647503136 749825985 190473666 347524127 783087940 392282378 997983655 111512889 688045377 129619823 860814633 872265048 641524363 927736695 13439932 988127141 262573385 81376…
Output: 637372

Example 3:

Input: 1150 445100 687507287 588119600 943303547 865373869 532223250 612569547 952887460 287631202 891755115 474326771 532711130 506157198 717795617 2233732 554672287 311457518 474177375 749889461 637649742 981076565 565436802 883297425 382114243 90149535 490237093 408456798 593816275 136808831 79590275 498138735 336404402 508039830 22463654 422118652 361149394 664395186 412236639 11612853 417859378 592049535 498525397 573749080 843662319 771930660 444092157 907421594 620975760 689466366 470964434 776275278 705387317 992406143 778030518 278341566 558275503 487974715 876586030 718275915 129213821 704634114 159736031 939811010 274651824 132596340 622067669 940115440 285219115 177312293 217881930 641371747 244027114 65233005 550010822 503505940 670806294 461564082 591417840 911440874 613335624 49386…
Output: 330050

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count of the Verdant weights - MEDIUM Coding Problem | CodeTikki