CT51329

The Masthead Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the galleon yard of Masthead close for winter, Yuri must finish the stretches ledger - one figure at a time. 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 <= 1311; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 24 464775957 774526439 555561726 765478146 428685059 251355334 8098741 323140326 364618972 589370348 996886301 993712071 48850616 89703603 583117623 751405955 317217715 118710398 504594613 826168724 938850724 674872174 379681040 184650167 334750351
Output: 33

Example 2:

Input: 1005 1067228407 743891682 332551094 696535812 477910963 416296235 272545777 967468192 412909137 164639067 848427286 401255795 397280618 971514474 778866377 618946598 959270440 117662720 22838327 380844367 735911995 71111371 598048124 82559961 754198653 557887816 894870451 77098339 667254233 977638786 963710114 114906202 16109876 120206611 281159460 155229616 417999436 805290253 685590623 798111323 257650666 275899955 516445771 84141045 294504709 228794563 513162047 141811152 233647167 933598361 669267403 191397723 896995103 885131964 233514991 333248598 753630788 351066638 680647930 429262591 761285903 749322442 6220211 859221604 864291307 867457319 149012757 948627403 21963881 836307823 649018881 960494901 638033604 539218943 318696402 595987781 138204883 58480553 763729628 70169345 46366…
Output: 282300

Example 3:

Input: 974 183353767 614337155 810826531 404336052 423956697 140751747 933716034 413738203 852441558 491130153 660571222 342147863 949291314 770406478 83813492 978926407 79414490 616291141 825589115 423726604 503753189 912209016 74781052 639441441 966081215 461929750 565925780 395542749 849758728 442559094 126970786 57686988 627150336 26931829 199412882 287018749 754190123 780297437 753742990 247177031 832677668 249738617 43385822 611203740 444303247 228557437 108836107 77462962 624960998 195263551 200214255 814215605 85469966 46293276 42328621 903988338 943781739 699718728 279592326 62857370 41627821 906715833 293210341 826946378 208985269 667829821 427455304 130775603 384061882 41306986 90356605 423561037 966656269 999046454 578432953 846284040 403978909 36501924 375095425 638249489 449086371 7…
Output: 8563

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Masthead Frugal Pairs - MEDIUM Coding Problem | CodeTikki