CT53824

Ojas's scrolls Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Ojas runs the foundry at the lakeside town of Mirrormere. 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 <= 2628; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1707 1683515301 378920667 520135494 982497519 549763789 31407437 628400877 422532314 214793496 156737990 295332603 370928763 335446454 353413824 216685211 993793225 648539008 442115908 124293163 416169286 290779309 349396829 187116620 553689416 649812564 668914934 337043706 463171834 332029147 672944499 301332600 142005377 180558793 865496262 831688762 210375034 956075451 409421580 249189236 344955598 931005785 818225184 440280064 969831620 686082741 940935085 847329710 936340285 310767385 106671805 5631814 515119336 388176353 80932532 247402140 690213217 971216152 301573648 184871063 96691200 24418779 2860940 993111366 80936703 76502666 519453558 518495989 468176457 556657289 60726352 466054114 960047238 744377356 950131758 352802358 703051135 486935269 838666893 992200589 84175909 920779…
Output: 1386544

Example 2:

Input: 2084 1871207636 549337787 388862786 433839666 829147692 768036040 665472814 665400737 746146961 858123419 431766050 82575952 162557148 344323222 49198684 218143267 801595847 475035819 696962665 957642198 167107505 958779353 917987597 758508591 405756944 459989373 583225167 167557493 744142207 199737754 303633904 729873542 441197694 177190037 867176831 976118261 815666574 285846439 205602846 92954353 366080011 491410238 531412820 906110040 93103672 350847904 223055712 546025379 988563294 748678373 766342403 914254198 537430413 291851163 222548034 763361101 337791895 42207576 583666064 951690234 777169443 945558167 643514519 131864129 93293094 923050977 460551753 705747705 874274303 466811413 645428866 646309322 169525752 860338073 729428211 130286940 146124152 378097129 139434282 199515464 …
Output: 2154846

Example 3:

Input: 2363 1453566726 36093565 639063352 902969365 556031204 809676379 683951837 831012477 404708947 977232056 184778233 871996447 382190471 976496398 360007461 979343698 368806905 967245975 612859953 763374160 119334132 143833135 672982706 803271288 155902681 615741865 230338422 284074714 766454864 832728469 493713219 616047477 867805963 989732341 889616194 497406468 198208935 12717804 548385049 869311922 347251554 993113 888230870 613301564 800953647 460494218 867190198 426109640 877589690 630601688 329774762 99166750 13290192 876265134 36696601 617366965 712914345 577097568 866481724 9445262 4703281 855714479 587621757 687399802 602775524 101032371 123540237 474872715 337449626 552278535 977839298 429998542 298995281 815012544 628259696 4205009 311496632 384877231 479233097 843658753 40627159…
Output: 2372593

Constraints:

2 <= n <= 2628; 1 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Ojas's scrolls Frugal Pairs - MEDIUM Coding Problem | CodeTikki