CT50685

Chandler's Disorder Count Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the bamboo terraces of Verdantstep close for winter, Chandler must finish the weights 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 <= 2827; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 908 640182568 429625083 282604735 473437618 637234451 86364706 45548151 84435515 -234519 884324141 97214349 614220688 597521984 948623606 358187924 304685294 789332358 193917019 435062931 121981077 421408366 865037792 572113255 514111530 941476790 532043357 736209194 690177744 660015708 576536966 538759732 227767036 305161111 479785967 941156669 580405031 648741404 254205070 446730029 362469002 466174932 288030989 878624030 731624281 447811457 121646216 398873407 561018126 848287242 940688690 287455303 67126649 477855127 132133887 399731384 786037128 657124117 606350131 391076918 97324960 546245515 320399845 782486427 468728745 28915856 918007109 110901266 74654414 690434137 413298499 52095778 985292259 650911527 527808912 659040172 513876292 488424855 200560078 417801200 534993536 5551184…
Output: 204283

Example 2:

Input: 764 793046336 543486893 384559972 210332434 884356356 433727392 724876425 163770456 472780832 107163418 724333695 57221675 88424303 162736330 795175496 397435505 671016315 875766990 96796280 420146311 485815710 135689399 288787265 651734004 192050798 469089172 609863077 817971865 612809899 490890470 613682221 212679964 90734777 916096618 814662572 271720928 148189162 462123956 554901187 652725247 833976907 812438227 87513644 265083900 41364127 595905369 663179897 582880758 898745097 631922112 147870671 7178096 229583982 609554652 157828942 63263603 639676020 553958253 762151545 752369723 71349081 464555675 558571783 518345956 160502567 373969349 326785417 981682086 794375694 245550002 709574976 718352951 417471664 173449375 758313719 753073096 666043581 554773377 96508360 5439914 597237703…
Output: 141895

Example 3:

Input: 61 956932170 260902738 699209429 519153020 362431492 715887155 519847656 32281337 767097509 764979133 405095843 482993273 857491401 65530358 850205039 155975817 662551650 242765752 437586741 259398686 688851174 95942323 56619581 900486849 878390694 265965545 125969636 308419558 51964051 308459583 216045717 61702700 262773429 606335091 964534546 748650356 355861617 341780395 75670086 631032338 507831231 984414943 792119549 7701600 744651305 811692804 829690936 850273321 325576946 537667086 304872571 274027603 359710698 754883960 427722309 403231422 311401683 257855953 243627169 162180548 116691727
Output: 983

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chandler's Disorder Count Ledger - MEDIUM Coding Problem | CodeTikki