CT38448

Shepherd's Tempest Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the lily shoals of Padmore pays by the answer, and Shepherd intends to earn it. First: the full register of weights. 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 <= 1416; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 287 262 208 38 58 65 67 103 217 123 182 229 205 246 21 216 164 200 99 194 267 132 197 158 91 167 237 238 227 244 191 94 90 171 108 187 111 87 71 172 160 162 76 82 269 140 114 168 31 134 89 97 78 213 235 154 14 57 54 62 175 202 272 152 42 222 198 250 209 84 75 179 96 210 275 46 279 139 26 6 157 10 228 270 153 230 192 278 15 282 133 206 118 284 249 261 224 165 141 252 173 60 25 211 127 7 218 146 32 144 176 50 233 12 184 59 193 254 183 11 16 263 169 166 226 4 95 266 137 234 286 19 259 203 186 196 285 23 102 9 201 239 265 44 20 130 64 188 79 3 35 81 1 56 68 100 232 18 8 128 283 145 214 83 268 161 113 149 174 112 74 255 115 245 55 277 17 39 85 177 178 258 129 52 28 220 101 2 276 231 195 107 119 92 170 151 240 247 80 24 109 43 106 225 264 148 273 13 189 256 223 122 125 104 45 98 77 121 37 156 13…
Output: 21596

Example 2:

Input: 747 566 64 624 726 323 418 184 348 708 736 450 53 457 166 139 84 68 120 324 415 25 104 296 535 655 178 153 135 647 175 275 661 689 653 603 319 435 251 663 21 8 460 650 167 685 422 127 216 434 138 4 246 561 274 686 362 688 76 562 291 87 170 512 724 198 77 672 13 638 373 470 277 176 302 442 59 725 707 63 154 431 17 408 486 332 605 587 618 91 642 57 625 88 240 643 351 529 89 287 727 115 554 456 283 577 382 597 144 739 300 631 697 458 244 95 118 195 670 386 297 248 160 92 207 156 131 128 378 558 720 123 742 628 550 494 582 271 364 559 590 15 447 630 668 245 276 440 20 173 744 370 54 149 241 446 433 41 505 555 741 253 237 715 514 39 102 525 623 706 292 358 615 383 425 521 279 517 16 235 595 611 208 352 191 395 699 354 504 42 60 338 390 265 483 593 22 510 436 298 213 129 58 105 221 2 594 609 404…
Output: 137767

Example 3:

Input: 970 132735381 319100263 234179353 883805309 616124668 851741261 307156460 890773293 503536514 218293775 133743886 412372769 158024902 587918470 382087788 137751172 453248339 262520778 612748742 914382812 799549199 461133274 146139368 382795596 714382785 887743242 925358573 167317291 535692102 467092925 412792531 350714626 376762170 980507980 210003816 513516706 711264429 121352487 875358819 241123411 259545972 599813030 40967087 722567879 43076566 819737772 991854137 682086758 668229420 107540054 384870247 765599267 941534509 609546467 762131361 651635868 31279559 771303194 702342525 154705513 483372721 908859115 741859039 662115269 885756242 86245897 476368973 850039533 483363000 519660490 404626934 355053935 26984443 591658875 354984292 413869168 124287713 762327594 437184775 788027567 1…
Output: 232412

Constraints:

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

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