CT63408

The Disorder Count at Tangledeep

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The harbor bell rings at the kelp forests of Tangledeep; Ysolde weighs the day's registers manifests and starts the calculations. 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 <= 3043; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 35 21736642 880923200 937647353 184413789 559960614 928062170 535823047 794690269 213583613 154866473 101609615 13341687 20011841 399289642 801611091 717287057 819449601 385992831 683598443 328963747 300403675 770924680 692483799 508455619 235724996 611351501 291822913 69483739 115097163 340858141 663908748 236979261 569709229 291479341 480932181
Output: 331

Example 2:

Input: 557 313 452 436 95 520 479 168 29 350 201 90 61 161 388 415 145 389 536 542 529 169 458 172 370 390 175 184 424 4 494 342 36 430 540 396 471 197 92 239 357 82 497 416 214 156 68 58 259 229 402 547 537 174 464 359 399 80 39 549 11 28 482 6 5 270 1 393 14 320 513 352 498 134 552 114 316 539 523 226 551 504 340 190 414 409 507 109 241 531 147 526 20 433 367 170 378 347 487 521 83 144 262 489 502 334 96 129 209 380 99 493 408 336 441 426 22 417 135 364 94 222 69 325 107 431 163 223 150 40 355 400 141 131 244 112 386 158 258 67 76 398 115 337 227 418 295 515 182 236 32 327 17 346 467 245 230 101 297 220 519 54 457 173 217 284 439 104 138 377 146 194 246 453 541 15 351 27 105 191 308 556 86 74 305 508 287 463 555 304 167 387 248 461 348 407 120 166 66 71 264 368 524 186 225 404 476 139 465 157 4…
Output: 80102

Example 3:

Input: 177 649027564 522267011 105250066 775483893 26147620 112199397 999514601 640109989 114519741 85753387 202420098 703147900 518562188 123185832 391135050 228209756 285497642 882284659 522225265 35889652 127947666 198106764 376810918 766491187 369211720 223129786 396068665 548204952 502846580 51980238 986212777 569580023 93609710 155932939 918061427 602340652 357256064 238606948 451654346 840721402 421139552 88358134 20299702 98400961 649187777 974083026 809874057 501644487 578562169 815772738 87086875 948380505 980181965 555151109 319688159 83621655 879631273 388066094 454009230 634034896 809305718 839072470 521255280 879605473 651302420 724708482 911058755 716899235 975706974 198449714 400132289 267291158 341496632 157073768 430165519 917220563 455674537 958103675 339378961 870510724 318930…
Output: 7672

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Disorder Count at Tangledeep - MEDIUM Coding Problem | CodeTikki