CT49586

Quinn and the Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The cartographer Quinn has been asked to balance the workshop's books. On the desk lies a long table of windows readings. 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 <= 2698; 1 <= a[i],k <= 1000.

Example 1:

Input: 63 63 925 882 848 719 953 568 773 102 456 455 538 165 737 767 37 112 349 388 267 168 627 192 319 621 206 984 489 898 982 86 112 731 141 845 487 110 11 322 536 798 471 866 508 554 168 499 754 484 832 651 233 501 500 450 44 364 315 260 537 175 499 265 691
Output: 2

Example 2:

Input: 605 1794 944 995 448 547 24 577 19 422 879 556 540 993 461 152 464 924 204 826 112 921 576 138 927 452 249 465 178 16 915 387 431 258 729 824 572 487 87 509 537 960 483 58 437 510 648 876 553 523 835 910 715 789 78 785 41 253 535 251 348 598 417 297 777 571 7 499 360 37 217 359 940 635 666 264 213 344 340 190 765 800 5 914 337 857 587 386 20 483 498 418 511 582 789 607 2 405 840 809 851 904 975 661 395 168 724 943 353 629 361 252 736 604 877 671 258 386 976 609 804 948 494 931 368 461 96 962 416 67 251 771 47 945 679 342 986 849 504 284 847 800 541 105 625 627 267 665 104 594 841 529 440 73 440 99 853 987 858 705 134 241 669 857 689 279 843 906 721 201 988 292 255 274 46 308 598 381 766 807 323 695 792 78 414 64 689 294 959 639 889 273 316 292 194 877 276 590 745 183 824 47 942 105 619 839…
Output: 179298

Example 3:

Input: 1771 1830 239 910 346 413 114 57 909 802 700 734 79 436 128 131 886 271 493 464 301 491 173 568 481 923 363 674 916 87 57 709 234 584 948 205 773 707 995 993 816 505 589 207 796 416 877 489 933 398 12 999 718 464 59 962 540 79 712 587 736 771 346 686 35 995 334 576 727 696 671 397 189 945 682 738 454 26 402 730 675 552 874 511 333 454 238 678 642 246 519 383 747 674 500 973 802 877 542 169 525 230 175 267 903 654 99 912 977 659 865 450 308 452 787 611 793 43 957 967 593 397 657 823 925 871 483 26 747 706 587 457 988 65 130 19 930 218 320 87 993 111 877 964 803 787 594 890 676 662 136 638 29 529 164 854 87 567 536 458 723 658 832 670 981 817 969 892 403 832 237 314 577 669 498 492 43 72 249 280 651 3 640 43 575 553 632 896 846 129 290 262 539 538 697 780 185 884 744 755 657 78 993 612 791 9…
Output: 1541633

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Quinn and the Frugal Pairs - MEDIUM Coding Problem | CodeTikki