CT55936

The Frugal Pairs at Greystone

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the shale slopes of Greystone, someone must verify the safety inspections. This year the task falls to Ivo, armed only with the stretches register. 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 <= 3229; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 2074 571333616 472708406 396949529 698262635 282306809 849359242 578353483 841210103 489877027 229765975 208773276 903469892 272559603 982661457 541702593 397309668 177975606 537351332 894656128 700852101 78727814 396824900 19580741 15966568 722903595 949234011 524279482 86552202 452753682 711462641 369747373 684951636 828266454 758619512 883752311 858756859 157432585 802092917 127250376 772150297 301494017 872761743 378689949 422570619 850217125 286445882 309457269 877564136 781001252 761108443 543274418 369903755 724055745 679339709 122550411 231328031 56063032 66582445 924134185 36319094 951709688 110295377 471137295 658974980 388960784 395748707 512172227 689388401 63400676 115255837 330491914 391775977 360208506 727070785 499529306 212086630 692710495 748306240 415425922 920808519 447…
Output: 333844

Example 2:

Input: 2 717833276 518681388 171415705
Output: 1

Example 3:

Input: 2394 155808985 441370736 22952005 432769574 58291019 944140246 406794655 411858922 887606393 320940856 807818495 32662007 9806567 633530002 492553276 983874077 308811972 875507006 897462947 13207562 555010821 357158336 310017110 839195377 246678787 285184583 698177564 150379788 651014827 196472320 972131158 779186329 124093099 559018117 204209026 131410354 902182211 911062979 972981834 281328402 115609087 306941275 559082133 611795313 675552920 839971463 258807454 709129750 62181597 259896634 597047146 63797144 951983035 590627556 727365349 532290987 659560444 375978690 618577544 448024953 678202256 40593301 540702939 538835452 916297047 227602221 890525511 173236186 348618189 916419327 140833962 827565901 952137085 734477265 641741167 639313025 990304331 492353262 104603715 893854847 9719…
Output: 43202

Constraints:

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

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