CT59008

Tempest vials Disorder Count

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

It is audit day at the honeycomb cliffs of Beeswick. Dante spreads the vials records across the table and picks up a sharp pencil. 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 <= 3353; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 1496 555881371 681667583 530482691 106839920 621476773 921123276 683855540 558030085 276249394 527057968 929016604 819844760 606713380 293425555 458187534 203362971 165585304 576572161 315286095 665114814 241776272 312383239 410797660 988579080 821421564 529295789 429250829 596643326 674574162 805405220 377047057 164671504 551328839 108414345 861904262 646921036 69869987 816191308 336423882 634073365 654095272 202680380 306341517 779006457 235750693 932634108 762934229 11176298 78823295 26572880 537146893 972388815 817594959 549890079 769833619 956350214 442300665 40128669 927200492 3452518 135515384 560880178 375771906 708819804 355241250 612347695 34064065 793973668 118220244 848866922 939514536 767646344 937299533 654882433 759160978 190160154 242682395 338542770 659567919 815534976 432…
Output: 552605

Example 2:

Input: 1893 28865777 61062209 907086613 397402916 848184697 894700284 992900304 951773752 350494903 617237357 949239872 626701676 455233197 606804245 216809577 878117366 533825499 575803601 983474235 579989217 877603495 32007476 621995557 360927029 155112529 611917614 374360849 357299551 837981217 38035986 842010973 184937766 473708538 368302639 937287035 43739808 865653771 212498586 728771405 515162756 820505869 935595469 876526225 414016609 513602817 682429447 850942692 619147317 161434507 179521427 79126940 315049582 227493950 858472464 304212002 891402511 372369499 827898367 871076015 511936452 77072696 32036357 734686603 287814628 221615502 694275230 115686607 661832688 823489225 796604078 265505963 740481905 76772402 475593145 547163905 744493411 734499850 693392399 895004814 542902250 4422…
Output: 899447

Example 3:

Input: 241 514210226 560047359 400593362 928562548 245511231 643275006 283458372 954563147 504740444 446782500 110498305 363915805 186996971 350145316 643399718 115074157 10536462 774218456 320017532 87122878 746315214 800753114 170105635 342431732 907960895 980891818 956317735 973461751 711669062 16805317 773947655 248905820 259636166 885724895 297065475 789668486 628746651 483379760 226333797 684586440 311108838 637464564 444345073 928360591 550369635 665494508 714904164 45547553 230538246 159405354 707405492 726872027 153452536 514242916 978579096 176889205 566311666 554307641 212153349 516053490 228014135 307131035 78387526 108160990 917710946 750321616 453265588 214134835 838783835 322151583 868091166 186209750 721767938 399647880 108196036 801287922 32583264 820928642 379532906 339248165 42…
Output: 14128

Constraints:

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

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