CT46998

Lysander's Wistful stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Lysander runs the boathouse at the eel marshes of Slitherwick. Today the books show a list of stretches, and the numbers must be worked out before sundown. 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 <= 1915; 1 <= a[i],k <= 1000.

Example 1:

Input: 265 998 199 977 90 817 674 187 229 67 968 792 537 683 854 633 847 889 67 369 687 661 806 166 309 283 230 580 922 959 296 993 992 86 631 456 710 790 843 326 836 313 831 731 314 888 525 657 593 528 9 985 56 400 204 156 525 905 436 691 642 597 837 439 501 613 875 990 184 488 32 852 713 72 994 326 570 647 18 906 904 643 580 591 860 918 838 767 885 797 537 421 5 355 678 572 923 12 884 978 355 85 520 834 268 938 331 439 109 676 596 437 491 127 902 878 38 333 608 73 516 371 382 325 309 515 683 774 949 476 214 102 731 430 171 725 144 774 283 595 166 332 8 320 380 253 68 993 479 73 538 646 704 691 43 478 118 103 940 681 552 129 227 462 393 221 71 750 108 838 509 436 677 543 716 653 750 393 214 856 223 878 176 772 367 920 71 547 596 704 51 939 167 307 234 209 134 684 227 967 297 229 406 589 155 328 …
Output: 17426

Example 2:

Input: 1304 720 800 361 878 362 322 931 536 692 76 344 795 159 86 698 973 621 607 293 208 808 556 805 573 662 851 781 986 851 807 724 491 361 816 103 257 749 768 473 127 301 869 541 140 176 818 400 101 995 460 97 161 954 146 226 225 686 320 73 573 833 130 780 354 456 492 221 595 583 482 998 573 680 631 732 353 528 339 184 738 319 735 789 404 962 365 313 91 822 720 653 930 976 770 236 453 257 64 312 838 881 41 190 985 687 793 178 845 438 85 176 429 787 438 460 47 127 37 883 911 403 948 505 869 716 120 926 834 114 821 763 921 574 595 208 647 536 788 766 995 917 785 14 281 947 337 847 692 282 838 676 717 122 803 265 447 7 182 975 1 695 432 897 435 42 766 520 628 795 375 738 573 561 828 263 631 514 952 696 332 912 258 424 18 807 700 912 929 57 474 910 691 957 143 448 849 697 582 141 623 780 611 68 1 …
Output: 219254

Example 3:

Input: 98 97 249 866 272 798 205 855 167 91 56 704 17 202 845 303 801 814 544 410 439 613 880 518 576 989 412 544 908 327 856 267 489 500 175 403 599 337 189 39 791 631 217 801 815 870 129 854 651 138 236 50 403 779 909 526 259 396 787 734 485 195 628 628 172 352 472 422 907 587 393 814 942 133 166 117 450 594 733 631 957 518 360 331 567 252 921 958 190 197 608 982 748 572 357 565 790 996 722 709
Output: 5

Constraints:

2 <= n <= 1915; 1 <= a[i],k <= 1000.

Loading...
Test Cases:No test cases
No test cases available.