CT36461

Ranger and the Umber stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the cork grove of Barkhaven as Ranger unrolls the day's manifest of stretches. The tally will decide the next shipment. 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 <= 1333; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 1176 -282456 548955 736049 63219 549576 -891086 891031 -264849 -211234 -352738 -335151 562567 497798 23965 -305259 939617 -180891 64783 365089 -626438 -659182 -701763 33708 518504 416698 -472491 957865 344047 925521 -557305 187499 -277715 -995317 467174 917208 -428735 -900494 73058 776623 409215 -374318 930102 -23464 -13728 748761 -636234 -540951 -228387 -601269 -965996 -916404 347884 76027 964291 -797786 -276954 411326 404002 971822 -941546 -982875 -835067 -369429 -344778 168262 -586595 -431965 -418893 -439996 709461 336899 573080 -774633 -658752 -708075 885977 -472933 -889827 -992078 -194457 -679725 71423 85878 -907106 -313857 669322 578253 592329 -44547 -674458 196017 716064 -837461 448301 176892 -385696 -294997 257110 214221 386393 41043 540289 88303 -689085 257606 -114169 -942675 -513…
Output: 269128

Example 2:

Input: 1320 1958848 669684 851583 -24743 717977 -740823 -328802 -839083 682612 585590 -495971 -544200 760433 540088 -627199 27571 -365963 72464 -830997 120278 -513098 -877727 -897341 121226 -827404 811712 690668 -748027 400192 -302819 -110955 342886 -228078 -504960 284298 -233195 -95463 664357 256879 81497 -27079 910055 44012 -235141 11055 -643995 -854026 197944 -155800 -9675 -639095 292432 429840 858847 -125510 -426074 99373 123252 931641 633769 484126 95130 -468197 3711 536726 359578 564852 -52709 373824 -137221 884030 -931383 342851 697485 -580520 320722 790765 -422857 879545 -294881 848282 911722 -241483 -680972 360408 735723 -320319 -305128 -449540 -663974 270170 -47329 -465701 -989394 -764359 43968 -997682 -564649 -739980 -744594 -673756 -188204 949115 74429 757406 653034 -705134 -752237 90…
Output: 870340

Example 3:

Input: 1102 1656803 -758959 -985612 935069 814573 71509 -50909 528185 -455770 -494414 -335497 -504924 376991 -490505 3798 910156 -152060 -751531 -982210 -236778 801095 -781405 483816 -850872 735051 -849226 153736 543537 542294 485481 -299880 -28646 -667167 -412044 -339218 -221372 -656146 365121 -464196 -356672 -938967 -68547 -272147 815122 -900688 -992865 -976891 717857 -624294 -565893 -948027 90419 357507 -968770 681582 628411 622051 -330798 -899066 182202 -470955 934945 -414593 338800 255119 -980660 -492361 -835699 -847942 -345790 635131 -289158 40256 -666296 601284 -833717 716265 720847 -333736 -148139 -113440 -185715 280348 -495965 -348820 -395828 -428568 216314 -793360 311663 -333729 191397 726651 795206 -316847 7579 -692144 -946017 19344 -654605 -262042 583250 -991414 890236 -311081 -69706 …
Output: 599228

Constraints:

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

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