CT49587

Kavi and the Shimmering ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Kavi the valuer watches over the valley of Misthollow's stores of ribbons. A careful computation stands between order and chaos. 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 <= 2247; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 933 1433400688 597167191 313127426 712824731 733241676 773024746 47378365 869556075 178976408 172979658 761791247 709716509 310467770 861431842 15994209 82895246 716922929 39024613 637370852 282323886 598146781 355392422 722982881 919517692 997898704 227383841 337782599 174181081 181439507 505366000 201547968 234098993 340359465 496520336 329724584 387955640 529951287 742069997 587025745 922724745 756466766 46036312 659071154 449411160 978356152 398044971 130355553 870760569 910737590 621206758 296561678 460962559 700660168 982833857 839354070 646136623 952135197 758851543 851553783 615316221 922940817 425628949 736032930 1581895 93164143 636601398 785889378 721507632 563817388 112897852 87345656 488473089 824589548 793381870 265010919 843136421 857799160 761167152 14644994 820606516 43486…
Output: 359083

Example 2:

Input: 1796 785504826 763427215 420016765 551998890 340335155 2576330 467493139 380525467 645002679 783839075 309279856 291473997 654001418 179522047 626134032 208100722 300888418 491797328 959899522 951268375 323879165 91794599 480105284 123425321 75375594 392409554 757747358 124874321 991673817 186000367 924685430 697156882 565724471 632991460 869030030 939078155 115323889 246711027 629675870 195018644 203664254 899484517 165604064 374860644 586079642 550723903 797964461 153140782 48597859 353348634 78765039 551774099 694652368 804300846 899521872 12097579 349763875 105643753 948888060 943107815 4666349 588466956 424613777 190870418 10478621 138516437 77349542 577751380 947317100 499909605 542199586 396934753 302225129 220424470 44692070 979757085 25524848 331314829 305835676 219679693 86729593…
Output: 490735

Example 3:

Input: 1587 1303334059 389622521 324590704 310890897 805402889 683444040 571108662 877921827 202957845 270035184 477606442 567970844 233275407 180452916 233894288 391345319 165965274 542816556 705125181 280203627 29358141 816291620 30297130 389805412 648918318 616635161 617130666 358920737 65626244 518660734 443622894 618180735 66478710 998590129 63117629 606596326 979754393 31719134 8923656 468488046 323372274 352908369 62208099 856514524 57373892 78536778 144424445 580178893 614558610 613334439 660995314 224533792 635385703 451471156 890531559 595189784 289828388 127807407 129055040 177343532 349492304 491297589 633547041 391172886 764256851 22860041 81779207 841168100 544160408 346556314 726901025 747360596 860724665 779681190 964476520 466556293 663439832 553897712 833806630 687682090 1935208…
Output: 952539

Constraints:

2 <= n <= 2247; 0 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Kavi and the Shimmering ribbons - MEDIUM Coding Problem | CodeTikki