CT44843

The Scarlet Plain Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the poppy fields of Scarlet Plain, Orin the archivist keeps careful count of the ribbons. Recover the missing manifest, every figure matters. 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 <= 1259; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 769 371765560 600222504 424405568 82665828 752236737 439959248 342310957 807633318 285027673 290936018 519370808 908362765 821503952 975729273 399604822 158510275 284098114 203821296 88596994 742023553 151989779 240104205 645652099 806683015 362009781 274640467 416619454 392945630 33651713 909196928 580998160 94437973 93471719 196820968 335643458 678749912 501075775 562430922 586941502 869733632 27650561 729442810 249160829 363189862 42235075 456191064 394824639 572218982 467794194 73216061 728523895 117570334 293698194 979392543 175066058 1253157 309333124 666749634 672128036 674391571 112942648 527332259 910594574 219657269 831177581 362819554 481915186 861213858 975283581 770208513 165556274 127819894 542577815 321073193 137061304 686834281 955298251 322549508 306840039 475410710 368982…
Output: 19514

Example 2:

Input: 581 1487591691 738553133 167840765 249601337 73323623 70308439 419855176 142508157 152485556 101594125 146995789 100005581 739136619 29243217 594611849 453613982 690230714 374634522 123656039 377210303 88713284 169715147 455609636 890419074 59932027 100559015 853204757 563136260 101469635 37620050 972395745 297586558 810941231 482822125 612089013 287025102 837463693 429207552 866706024 405485418 699549818 861788486 385211964 650062002 693131805 963453798 554922917 271948511 511353013 867390485 608074648 712922601 527788659 648473385 183927140 994942799 582270782 558996554 986857068 854897789 563377791 466850381 616262542 363298791 690602415 533064659 751378046 551302438 914802246 920318443 920950575 314292392 570035515 942238147 879490013 294166188 125733021 178214959 917398112 693071867 4…
Output: 146011

Example 3:

Input: 251 1151123957 565453865 122272033 13969150 965693659 153380438 850849595 956779763 772987509 241786277 115301347 728576558 152114940 157402632 616909504 458523854 249690250 343553003 399589664 903815058 414128788 216605007 979077193 37541654 845096339 188610452 136257300 921391251 857704238 461795731 340915217 150462174 429488560 779603178 801819669 305426905 928830472 499353760 13165075 149857727 964783550 532338708 786734210 238587710 721739564 828858062 294846857 851986801 160590536 392510098 624928123 241967091 141817963 852534457 808679820 94401772 74273566 121356313 270860918 112112084 224826129 64629897 461571607 835665417 452088135 706940184 103394527 403984367 287860976 796922604 962315947 687984223 913854396 284722752 183752514 499807570 949782671 161579617 18102970 762409330 90…
Output: 21347

Constraints:

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

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