CT32803

The Bright ribbons of Admiral

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Admiral inherited the fish market at the orchard lands of Applerun along with its curious bookkeeping system for ribbons. Time to make sense of it. Task: Print the number of index pairs (i,j), i<j, with a[i]+a[j] <= k. Input format: First line: n and k. Second line: n integers. Output format: Print the pair count (fits 64-bit). Constraints: 2 <= n <= 1308; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 771 286905824 837797425 851961387 44348139 713482921 506974745 872712325 872495000 481041014 699524506 154404392 73314286 740552251 721749077 664970961 754266366 199412031 775772933 49486746 170728350 315188771 895672127 207911281 986988447 673441755 283311259 729109133 776324497 533476017 335480142 520870538 955855459 838210492 216714448 269752335 377660090 987575201 136604676 240766994 589586379 433759930 355101395 750418194 981101641 787175382 771776055 624627738 109856192 107031885 624184982 414752348 163425943 465281091 788367317 465019475 463140916 114905303 684325062 2134016 242051709 670011997 188494016 391924724 258798000 200654967 969050567 435254355 659668031 768414549 141029247 819395576 325812878 682504071 364607368 931651078 149625075 976437351 436561931 -593476 332293950 654…
Output: 10945

Example 2:

Input: 732 499476650 935438390 166845889 16320276 284187210 957772664 19199239 426510924 599742602 490423875 33529676 409011288 735800111 788930250 863124560 984698556 636586356 922616829 727764977 301343272 581567682 84051560 381335996 671679814 540065455 752615314 562350015 835287700 453841618 12439627 428385758 589004611 826588171 44216625 232033984 519780685 558884917 816937673 64234272 317265474 466292153 495937706 811976606 194609047 471496811 730208520 610810933 952023538 493704493 94152847 954050633 488707529 416005517 945764118 209699662 44563568 880174323 837929616 991089725 725890895 674063310 180164586 148969506 100338872 614526170 892907900 317762739 872564772 57820780 859537269 824827012 309924505 941670104 989854105 387435153 816194 287657626 834486458 935776092 92132427 166044697 …
Output: 31543

Example 3:

Input: 537 1163275287 754820157 431995381 781994250 956191648 362994452 263611303 831612295 426135250 273900541 499945603 710083614 803397180 74295324 929517455 962592079 500183834 173654589 305163708 714729302 74119233 832986734 570669936 458685025 80809967 359929277 213644439 341811415 288666336 425223247 244049551 113417572 715037596 130600815 157047522 19957925 458595069 602432540 146135674 727097603 929664503 340669111 598730743 733225883 824393310 958383315 901806835 761335950 126547182 719615327 310856382 865318047 500689867 13352026 455867039 517226089 816815425 541640179 704474674 13167791 990549710 36897138 213757402 862480160 921318357 650146988 712705442 361570790 896161883 580397523 642577190 868157812 784152915 22055487 403610108 374975449 562043857 266004695 124533477 355176177 609…
Output: 93855

Constraints:

2 <= n <= 1308; -1000000 <= a[i],k <= 1000000000.

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