CT36930

Nils's Gilded Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the fox den of Rustwood, Nils records each segments in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3663; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 872 940354335 705328399 591314569 854743641 294092515 440584282 180525776 785495389 458074926 722613379 243516225 913513337 776386939 559304302 546944634 655725732 176204886 647896061 88717044 590366967 286090728 437590681 638328491 287192447 491462713 455731162 963224374 303941511 311920712 932768581 982667031 236082317 741747241 71638096 685559712 139286832 17114017 381355811 347083186 199118758 305316431 119187508 150308627 575945649 345692556 409335440 957588418 549892865 997547958 561655097 431359696 326179575 559546483 708035105 540017210 702997999 459008749 70706878 436920628 855182656 912731608 576900656 656403056 362859231 685475575 843184114 458814476 458251747 75076497 904314861 371037017 885348969 272295561 572765345 193963838 781845347 807204644 326351142 815574890 713408439 5…
Output: 168586

Example 2:

Input: 673 1695717896 283991870 178113412 300943193 215037057 199442579 599052062 803506452 734311313 942510023 416256683 117262965 757791077 697442306 980697959 658683927 428694035 988161367 897179144 919811626 832460954 40040136 997318755 134986232 476239423 990797912 498718267 806865106 326224208 862616157 738986364 766814026 306920603 849080406 769817204 447992634 330606469 690467114 270521161 330712443 412961366 546291347 282802098 971153961 342207756 578183826 579602784 31411222 242786301 353792770 551486176 977450102 861454170 248800254 72337302 797954761 301103698 28592236 768421876 394317160 435671833 145870254 74664371 794468806 510455955 511903400 617521571 138304050 485084238 584586602 726419989 298795881 567635534 183624057 185792287 17014000 222359994 347099770 565641408 240002875 8…
Output: 213124

Example 3:

Input: 3491 407922083 703329123 978945517 917845332 177700265 13051670 189121946 40400028 997008548 857298691 920731856 954480115 44343745 177543670 812912943 993479243 899256250 340214075 723382304 689256749 637962793 663952976 961444464 294056672 338313763 111667469 340604084 500899057 604211492 360658628 335098624 855282699 822683236 623607452 889085109 586103746 257714581 46321683 64148774 864003072 976779859 651835518 34274536 670461129 221329738 144989915 360146954 494637366 611687105 51340743 326739847 307332382 959712722 868272918 247214852 82401587 635140973 58396754 744545339 513544725 818949130 929556145 125324300 992313249 887457370 707814244 687651580 304282367 605620442 357886970 697270166 974756509 382334459 830453466 217180939 524593827 512893070 169374880 194631533 378369783 5062…
Output: 491024

Constraints:

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

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