CT65022

Keeper's Disorder Count Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Morning light hits the quartz ridge of Glimmerfell as Keeper 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 <= 2575; 0 <= a[i],x <= 1000000000.

Example 1:

Input: 2504 415383115 700652127 751981088 552225791 306971204 805131788 353985917 250879091 539159469 193163013 461137913 828161793 178538127 473869248 337432191 530474065 868815510 218394938 358579443 511718102 919073697 972213187 589850945 364583182 589138079 92392914 727639391 660576941 423051891 735062299 29593438 747470802 382952776 452026800 393765297 158347913 667879732 4333594 310737496 92548736 772016033 390225839 635755486 582573869 944100518 669670622 249516396 20449387 61532642 184168052 569203965 656308916 851697793 280896924 727403101 797523542 154072290 609964663 647111252 861340228 981660155 912569806 25183013 959559634 315092675 346332346 780297579 488319384 33747822 201791853 857564618 925651432 854682838 174048165 747460942 996735414 687029946 778097987 498034465 952787090 8602…
Output: 1586378

Example 2:

Input: 411 202 50 384 39 70 15 377 1 219 337 130 326 114 305 280 180 173 410 297 386 315 131 379 126 33 338 38 197 266 141 293 256 368 167 111 207 79 263 206 385 56 391 290 162 122 231 90 397 398 323 322 121 83 342 262 48 47 61 143 261 59 343 370 331 66 232 401 172 145 166 203 127 292 369 227 44 246 23 5 71 324 300 361 3 159 223 366 268 289 177 347 371 26 327 296 191 380 46 291 64 248 118 82 176 267 216 281 239 43 179 80 19 65 86 25 402 29 171 407 383 257 189 85 240 230 286 396 96 36 123 229 186 67 53 168 165 16 158 362 178 193 374 14 250 388 31 182 355 259 314 149 302 129 260 346 156 117 273 205 345 313 105 245 42 98 275 376 294 238 252 330 22 277 7 187 318 41 400 333 352 340 78 161 72 373 279 311 102 198 328 106 110 69 249 91 272 382 18 137 210 217 63 316 164 403 37 319 241 299 115 138 237 77 2…
Output: 43264

Example 3:

Input: 1662 657139837 31279232 51773924 778635440 920344129 828219094 205383618 177592974 298908771 563738721 157642889 871353426 181994779 913635235 157892143 457309211 428950994 746078856 606326619 627730177 152022680 316865643 566441463 820491853 128475366 89157921 756166741 277561245 873439713 277705383 280047122 181956339 667147805 2749 542366942 459037722 786494151 193418070 305984194 359651747 168778362 155134871 737865260 361663675 641385367 722679555 496184436 161381145 249120996 26909266 402982886 809702077 611858140 513880912 127709572 284216014 31606203 326207161 51196855 203169863 55456119 625458355 741122625 400459066 807071799 520270524 464908843 582654414 377490383 690604819 35097918 696676822 555083180 126091759 806038585 355841776 617667028 635938136 278285355 883010520 28488312…
Output: 688805

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Keeper's Disorder Count Ledger - MEDIUM Coding Problem | CodeTikki