CT62473

Gail's Moonlit Ledger

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Gail found an old ledger of shelves in the aviary attic at the maple sugarbush of Saprun. The margin notes pose a precise question. Task: For each position i, print how many elements to its right are strictly smaller than a[i]. Input format: First line: n. Second line: n integers. Output format: Print n counts space-separated. Constraints: 1 <= n <= 2066; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 1492 691778 -539760 -869808 260778 357126 98680 -213144 -331225 879680 -948473 -917491 -717965 830153 369727 -83566 -829884 470739 -338694 -889994 245901 115883 -568795 -830052 -381928 310006 47248 -524031 -216304 642782 -735749 -122671 174669 -899068 957652 -811728 148696 384645 -659568 -746805 272216 -912761 -622929 -821070 457349 -439330 -28873 639202 72482 -245805 -645979 -191831 -464525 -743478 103651 696780 -773246 -749865 931598 -520736 655958 993565 -96897 -17908 -427726 771682 -733095 -117743 -914637 924650 -711305 -847012 508952 -986661 -730930 -620528 -4648 -336336 -281233 -768928 -718821 362404 -955971 103590 -362738 48207 -62159 965983 691578 -430595 515650 461058 27242 587492 -883439 -224987 220256 420952 -747161 717526 -895592 -82253 -555419 -97904 255221 503686 907617 -8081…
Output: 1276 338 93 946 1007 817 565 482 1390 31 57 204 1358 1015 663 116 1106 470 78 924 823 308 114 443 957 769 337 551 1213 188 619 854 73 1414 132 830 1006 240 176 926 63 263 118 1073 389 685 1194 773 525 248 560 369 178 792 1226 149 168 1375 331 1196 1428 624 687 393 1282 180 605 60 1360 194 102 1094 13 179 253 687 442 483 146 184 956 27 771 429 731 639 1368 1198 381 1083 1039 705 1133 74 514 848 1000 165 1204 70 616 293 601 871 1060 1309 128 133 738 1364 390 1257 253 1144 1049 1046 226 929 1151 598 1347 1264 755 1232 298 237 1085 208 1146 678 620 163 1251 959 689 782 1277 81 383 536 1220 1119 766 1041 1329 346 482 756 378 771 741 1166 91 631 488 51 472 415 1123 8 82 25 919 127 479 668 504 1161 684 1216 226 1028 601 1074 353 633 1132 663 829 312 91 1077 440 942 73 941 930 716 132 1016 349 175…

Example 2:

Input: 598 870036 424679 -59809 -732652 953661 289653 228264 266743 -789064 850778 -375583 361699 -737279 293749 -677562 -47882 -773018 259351 -850475 -52047 975590 -961626 74167 127698 272412 207338 663944 618675 -547251 470139 -394313 110178 651129 940281 -934640 -179886 -147491 605303 855324 -458020 682748 119732 -13628 -640661 506362 -493001 264722 -102120 748782 -167110 546874 297033 146411 237006 563184 610506 -992157 742403 990995 946588 -761403 141291 -774936 380619 599999 849411 -744352 381253 -459681 -981639 966520 -530668 -457825 -598892 -126640 -495202 754417 924030 379851 855858 242082 -186124 913890 246762 -15393 425288 -250274 731532 518539 544527 760506 680203 -110429 -730981 456660 -413322 -718470 14637 443371 -107937 801411 504416 -617372 -480204 571638 -166376 151092 486887 -77…
Output: 564 420 281 80 580 368 348 360 58 552 200 385 78 365 95 282 66 352 44 279 572 10 297 311 350 332 472 459 133 411 189 305 462 550 18 231 242 447 526 162 470 303 278 99 410 142 335 254 484 231 417 342 303 325 420 435 1 473 538 527 64 299 60 360 426 500 68 360 155 2 520 128 153 104 233 134 462 509 350 490 313 216 500 312 261 364 205 446 385 391 453 430 233 69 368 166 72 260 361 231 452 372 99 139 386 214 280 364 57 421 458 277 130 404 121 446 257 237 171 92 98 357 304 8 377 127 419 68 191 162 236 275 317 359 286 365 308 394 25 122 327 268 113 219 262 311 279 430 317 57 73 310 199 321 315 327 359 371 87 309 254 12 344 198 259 29 411 115 333 107 404 129 82 53 93 78 280 419 152 198 267 151 159 289 328 91 319 86 301 230 201 191 114 223 44 253 255 248 41 200 50 150 266 26 112 24 346 143 369 237 30…

Example 3:

Input: 32 -790803 309539 -664397 459896 416793 -949966 -376735 999351 60397 925567 136294 533429 830664 -824387 -982296 -902191 462310 254638 534587 -108524 229142 -49001 880727 -135597 280427 -415972 453178 505594 -521387 -616769 667367 423482
Output: 4 17 4 19 16 1 6 24 9 22 9 16 18 2 0 0 11 7 11 4 5 4 9 3 3 2 3 3 1 0 1 0

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gail's Moonlit Ledger - MEDIUM Coding Problem | CodeTikki