CT53600

The Silver scrolls of Felix

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Felix runs the dairy at the cinnabar mines of Vermilion. Today the books show a list of scrolls, and the numbers must be worked out before sundown. 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 <= 3533; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 3128 1105376297 478141497 890476455 326119458 759606533 812285630 450912689 687176859 965742217 475044848 254984095 524544415 776310710 126792720 12231515 589716138 67195992 497875280 24238183 933805564 482882935 563571597 559192276 906613974 819997328 498288307 368883419 220715398 745365710 524693003 620555505 643992720 402266749 804515492 915904006 952621928 742987511 106365400 648119274 216555469 439156561 478475989 583190320 29856400 711259609 737481889 821715873 477634180 196216559 204011379 700661297 809682085 541176917 709336040 331670344 925534690 910534528 550287157 885192807 298526561 828058067 388577465 70276457 804413685 420401397 641188744 319882499 110103694 365238331 349410523 860203022 222493083 709654023 849695130 276868399 535828051 875123485 647656761 54495340 998788297 …
Output: 2893445

Example 2:

Input: 1331 677790033 367958105 813471403 245106881 864714038 889298152 606485405 956105639 838941175 949313957 220607053 74955847 515988348 754305586 895311529 176040878 435641394 440938602 97107732 668556560 86024395 636899548 547407607 695109996 195496542 545036350 462326679 40970362 119831927 249206967 938312720 154592225 697098429 394982265 210031690 851208967 849818873 939249064 107550449 150604755 920325904 428603539 955573619 616269803 627540225 648492360 128784286 338524062 31726025 214625833 320042071 510987364 442232917 281938283 124692172 748125409 117727752 410534808 355198357 73096971 988201783 255139083 429798220 436931147 376932225 837988528 499513013 876896673 593828455 638223903 553078108 90712156 388618104 543920007 839847746 810549595 563974296 591536015 405207734 498901726 91…
Output: 220281

Example 3:

Input: 564 809577947 155171 881973450 589396908 853834000 271814781 918315494 957802938 127688651 653631017 551873019 341852466 876160161 984536943 464987404 994032195 516457453 603064833 413231619 153501088 560836832 136615549 565673044 453978004 186517511 441115186 864910352 555866099 276444372 427896003 228459144 80960090 635212207 700850635 231819850 450213180 258523980 433493490 600243682 633953065 582823319 778161223 444748392 659063785 293660339 267500815 559155156 344969351 621866881 373654221 333023326 672436731 833996056 600835030 112512187 889127130 246147275 590784195 609562551 235180328 642869339 228072188 597223862 5002041 938291919 522204953 431040731 229666694 257164260 136925034 831481627 193917175 959846039 366097936 322022869 852617149 779014813 18035238 381910101 224199067 511…
Output: 53916

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Silver scrolls of Felix - MEDIUM Coding Problem | CodeTikki