CT46508

Theo's Bronze Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the honeycomb cliffs of Beeswick as Theo unrolls the day's manifest of ledgers. 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 <= 2260; -1000000 <= a[i],x <= 1000000000.

Example 1:

Input: 408 312 113 321 102 124 6 149 56 58 308 226 39 96 388 295 144 93 11 62 108 328 55 132 264 54 148 290 369 165 65 315 184 29 128 353 127 22 34 179 182 358 166 161 68 276 335 309 253 200 239 126 398 345 391 23 327 244 368 88 333 37 30 134 337 145 268 123 317 211 318 254 15 394 258 406 119 302 373 364 209 75 42 50 20 386 375 248 160 46 371 229 67 257 236 60 347 45 303 169 260 85 164 121 218 35 378 404 300 64 326 78 219 210 325 157 173 203 3 330 334 240 340 237 283 130 278 156 262 336 289 1 243 25 341 12 395 356 57 69 361 178 350 285 104 73 374 382 187 185 192 313 314 122 133 207 116 227 363 138 109 51 274 323 305 310 129 389 204 292 86 139 171 311 208 380 216 263 53 284 249 319 372 131 188 117 405 176 146 245 115 252 198 81 24 255 89 228 194 214 199 175 231 220 365 273 5 296 125 118 26 294 271…
Output: 41598

Example 2:

Input: 1565 344 916 1482 345 682 675 447 1533 1432 247 1410 80 1150 1157 796 850 583 1237 1141 1139 1280 68 1285 1431 624 216 74 815 668 1223 1037 1345 160 259 1281 1297 1075 520 300 325 168 1382 832 685 1439 1414 899 45 1342 1425 960 1244 738 1471 532 1331 721 895 856 419 877 1152 912 1395 735 257 163 958 279 643 724 1287 1107 717 1551 1144 589 463 1550 1016 881 422 833 420 372 206 1113 221 1030 1526 1284 750 1453 699 327 1122 1151 1340 1316 1396 1385 578 910 601 826 1334 776 96 28 369 852 613 382 1556 434 1111 1259 407 515 1146 401 827 1040 1452 452 1004 213 435 72 25 275 714 674 1441 1483 688 783 103 1079 1536 1059 666 1302 834 472 23 175 336 1131 533 117 871 560 851 686 809 395 355 1321 410 545 127 592 437 802 998 296 1521 1455 938 348 1005 845 1166 1514 124 999 358 1271 1247 392 1436 1145 89…
Output: 627491

Example 3:

Input: 138 616131210 615492225 145514915 404217135 384191639 29232936 343982708 865337561 35088316 502771099 317090019 629644994 938206656 635477665 167653669 49221126 662588612 130588261 334451167 590333755 174107863 530324438 250965410 511723913 272126757 280672766 380033384 262334116 25970986 505847365 229749472 871068984 839878174 485901321 79088358 910219535 266054289 737460499 217275736 555382377 608114564 126590770 501401896 627514251 895379193 153504766 545051362 748362607 356524660 58055568 378693902 412025464 245872195 7030829 644842549 414191648 929856900 787663103 926708699 406721905 628028034 180910559 186661162 160168361 627886940 35866409 473038457 31786538 290906299 900423996 378538507 823441677 112698220 680318061 341446793 302731302 992126240 815868715 187166590 125017395 413217…
Output: 4637

Constraints:

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

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