CT59928

The Hidden crates of Cora

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the snowberry thicket of Winterholt as Cora unrolls the day's manifest of crates. The tally will decide the next shipment. 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 <= 1274; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 658 35195500 583895426 611231719 122705380 883610788 375707485 417575843 343109621 435529469 342857377 37032924 670842346 892858985 866563695 138984879 715313185 912649549 145016703 950039122 103541972 84860415 742779873 215414331 81892411 245554184 437701452 552401764 850177108 946880694 447729183 67746030 960436548 136997686 546697226 546695793 995001327 489015932 403329245 317756002 724174392 626760156 309987530 315621509 873266123 299468336 155981383 130207054 494793532 438171793 874744934 422477979 184112941 952676639 789383403 355888750 955299998 472123459 472367587 570123380 358965831 130497406 542951084 739488200 337366771 651367852 493848231 337842635 265084222 522035699 436586853 799390252 593533603 905792577 416532600 980652193 574167691 16875962 490906283 871787671 605764233 78…
Output: 105757

Example 2:

Input: 663 313 496 329 495 602 213 261 226 400 192 48 596 559 326 660 450 33 228 9 642 476 483 352 485 542 433 557 375 58 538 250 221 587 470 521 291 186 37 525 90 109 146 536 631 645 54 303 180 15 278 397 340 612 337 515 362 149 655 123 27 129 229 82 659 529 584 19 567 80 45 211 516 134 658 350 307 165 380 556 481 447 436 533 500 502 432 338 355 466 294 467 657 576 236 231 625 486 361 51 423 124 197 88 635 653 357 22 591 81 244 153 137 83 248 549 311 13 419 422 193 345 399 189 108 68 554 553 309 580 403 128 34 273 608 474 284 437 597 217 43 130 300 257 243 115 21 473 421 629 74 11 586 652 318 26 285 8 246 534 579 224 323 604 136 55 39 67 595 138 523 69 77 172 87 402 75 377 561 249 185 325 2 461 430 520 210 382 455 125 308 279 594 366 235 519 546 617 589 173 44 535 5 532 394 84 458 622 386 661 19…
Output: 108665

Example 3:

Input: 175 37 80 62 106 115 42 74 133 32 174 109 70 45 86 58 8 93 153 14 165 139 103 20 101 48 81 118 157 88 79 170 145 130 138 51 0 149 131 53 6 1 46 67 116 135 129 5 9 111 33 15 3 112 44 43 50 125 163 144 158 52 73 64 59 173 102 169 94 39 56 63 134 57 113 142 117 17 92 4 161 96 123 19 13 97 91 162 110 87 155 35 119 23 159 7 124 61 95 25 127 18 27 47 152 137 120 71 76 66 172 143 85 83 40 99 128 30 126 105 28 65 38 11 171 54 150 82 147 156 136 41 151 72 148 10 60 146 75 2 168 160 55 78 104 100 108 68 29 122 141 98 107 77 84 132 154 49 114 90 89 69 31 140 164 167 21 121 166 26 12 36 34 16 22 24
Output: 7528

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Hidden crates of Cora - MEDIUM Coding Problem | CodeTikki