CT56559

The Bright Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Every season at the gull cliffs of Screech Point, someone must inspect the delivered goods. This year the task falls to Nandini, armed only with the ribbons 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 <= 3443; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 1902 -112707 -106679 -272551 -560087 -568213 333664 -41721 245842 -567130 493106 581088 327426 887280 912031 -844060 387957 -76474 36287 497235 990534 -185171 -669846 180842 -910905 -557713 -51753 -677351 254998 692316 -822270 -120101 554894 872758 59410 648505 817747 109295 -300995 795628 578665 749696 443406 353475 -336329 -116421 766485 113667 -293947 605532 -11565 -559874 -624408 -207755 -339696 890029 -460833 759449 -355694 770262 784031 539326 -700945 328650 -754453 -575612 -753239 291440 -465660 562673 -489345 -739246 -546642 -383505 334693 459023 34898 112288 -795703 752771 751046 -602442 -697417 -433376 -849768 551744 661013 -774420 417534 925479 528154 -843020 56050 593039 -381083 -880315 -964902 211685 -622552 477045 951816 -515087 737865 -611118 -399941 -902559 181122 -624415 7…
Output: 822802

Example 2:

Input: 128 1659134 -742930 -370513 34986 271799 301658 -450611 -211026 24115 -398290 -428219 756650 325375 -97220 691881 -752164 -443686 -233600 -424730 -392253 369096 -746326 561407 -521612 -703299 -153427 -381574 359570 -211495 936945 -431977 406671 -726920 -571826 -877231 -794214 475691 -141397 903453 672754 595365 -152518 636948 280138 717869 -218147 -667648 -852840 795523 372359 -618890 100560 657132 -336198 -612180 642883 215690 -299144 -116673 541169 958583 -324361 -507814 934577 -996153 -890073 -568052 63398 922671 -528318 598182 -941595 -26925 -111823 -25303 -771587 -222615 -266296 -572036 -787898 -580176 -999276 94051 -981458 -315025 857773 -817832 -579131 230627 -925976 37106 -834762 -740546 769810 -50820 -558658 289949 121634 -80985 -233126 -296392 155444 893475 1334 -507850 438708 73…
Output: 8078

Example 3:

Input: 2840 464726 -778894 -160289 -375345 -395833 453158 -258048 -998666 -303845 -849047 389816 233284 865538 -300555 620956 -638946 326 -95081 -894397 -781476 -587736 43059 -908878 376633 -404748 -860917 980801 -148270 -506200 223636 -966281 605596 251937 584098 830693 744927 -360294 774994 -573090 -435076 288440 -785752 -650083 -443393 946410 297849 539808 -559628 -119444 -759766 -791508 218779 -540994 -253716 453543 311484 279179 111853 809355 505731 540123 -774516 834258 662884 -960907 -429973 662873 884344 978132 -586970 -138843 -865587 -18271 448381 -986281 844901 -884350 -260492 -237671 -355654 555632 737694 630069 -740347 -977009 -227136 633926 359210 910447 -676038 -914914 -918455 345329 446024 -756125 603088 -257242 758208 -201308 59397 615983 838854 299452 267511 267801 -485958 -83186…
Output: 2817232

Constraints:

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

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