CT59085

The registers at Tangledeep

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

The council of the kelp forests of Tangledeep pays by the answer, and Yara intends to earn it. First: the full register of registers. 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 <= 1689; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 625 427 388 103 185 554 239 227 347 519 133 105 240 107 602 63 360 494 461 287 528 378 374 146 46 75 174 420 345 492 622 18 498 34 495 396 500 132 112 220 184 445 512 120 16 607 33 263 587 14 417 52 340 433 329 267 573 223 341 201 600 147 356 6 124 285 238 409 122 310 438 261 70 270 334 436 317 380 204 364 166 549 594 452 24 381 225 459 283 411 137 577 64 69 592 291 430 609 262 202 173 203 402 213 94 249 256 567 556 305 182 429 42 505 235 418 551 303 297 281 485 159 207 250 476 472 10 176 217 151 460 616 38 157 7 339 292 527 192 355 241 342 550 40 526 212 525 361 426 421 91 319 467 236 141 568 562 499 206 215 23 36 156 246 49 621 312 171 344 348 25 162 136 244 564 17 43 410 160 27 67 85 466 111 108 155 553 333 89 21 478 503 508 288 566 393 352 506 77 389 397 179 90 477 165 269 59 358 390 4…
Output: 94746

Example 2:

Input: 1311 87282960 392692867 454352462 476262000 464863727 184054796 853123050 124338068 365178254 612525305 564709204 88309471 396336796 257892341 349062443 402888054 877002525 419061493 547575839 576954861 893231870 303550503 652021044 5633427 873647979 369867087 525011311 820299402 270910956 291701136 831894154 465272819 360574387 323771731 61499269 488088405 875692743 532122375 137749699 644693304 528694711 259623148 495860579 815478523 422216015 462435997 362403867 935339014 638128574 362440240 22035158 973382516 980335529 182191212 803002252 746257694 729128813 351372795 46943589 701939349 357981959 740422826 187970776 658324994 717049368 218901601 722133302 824058538 986634602 777776350 31882128 209177776 459730864 839892919 361333870 515923723 489585543 313736874 437491698 977621199 708…
Output: 442788

Example 3:

Input: 1666 650629090 692832184 717503479 609779946 22061356 499018298 631688673 331723052 704100644 856292647 247202257 81188740 55084806 655089240 133181442 402423774 894481903 418574506 365689438 956064233 303731523 222645152 658343364 661851364 881561335 952967318 980329972 761704648 854565227 242767779 390304050 471989437 372758306 781505227 117905947 633597328 659250970 943296406 357594687 237219309 600077916 354114556 335110863 979140468 255910244 833838079 789310136 350070393 443126304 330774085 849109527 42849012 413901890 53712392 959847067 335928211 604521424 49660974 771802127 8942548 839445646 987814256 484587879 100318651 774104797 344461775 863718937 400451080 762558041 607871128 851386844 285424232 293269694 135476518 285189267 635559596 806489924 807375899 986841330 893952398 239…
Output: 700723

Constraints:

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

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