CT30764

Jade stretches Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the orchard lands of Applerun close for winter, Lamplighter must finish the stretches ledger - one figure at a time. 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 <= 1330; 1 <= a[i],k <= 1000.

Example 1:

Input: 173 1869 927 444 968 398 401 721 32 684 467 153 716 529 540 265 95 674 466 628 315 521 52 572 173 712 424 299 856 944 28 196 234 939 568 772 609 362 373 232 304 636 843 371 445 191 936 951 903 753 231 637 309 544 871 101 706 880 105 736 839 982 479 645 565 36 35 507 468 938 760 644 199 134 671 53 857 342 919 136 548 97 151 333 145 576 743 179 826 632 352 517 47 7 500 981 587 934 181 218 526 200 77 599 670 299 720 383 83 688 358 64 629 581 740 14 536 709 345 178 767 736 426 552 505 470 857 861 848 476 191 619 489 970 47 173 102 57 887 838 189 401 32 258 402 587 478 388 634 387 527 63 577 311 555 802 149 51 198 871 754 940 270 751 564 168 647 520 99 741 797 696 269 680 800
Output: 14808

Example 2:

Input: 824 218 845 26 265 725 369 380 952 939 633 837 309 802 709 9 485 78 155 431 584 565 864 622 662 588 776 836 555 276 261 328 948 489 967 451 470 653 342 210 541 158 97 309 432 518 463 450 240 257 529 379 653 420 475 301 793 384 284 453 798 891 894 311 703 16 557 457 854 9 123 584 810 676 656 125 847 244 906 588 961 79 371 945 471 609 840 737 250 363 183 930 931 733 529 249 208 309 652 197 324 812 532 771 711 700 99 248 208 990 771 784 201 642 544 220 958 315 873 66 607 254 316 762 489 219 769 844 236 132 468 615 920 952 31 995 888 21 573 886 385 40 393 189 15 969 133 147 391 377 774 265 933 887 537 137 543 381 503 839 512 108 937 556 143 950 521 528 174 436 428 292 707 578 683 454 24 803 285 9 779 531 931 140 351 567 68 388 170 746 395 637 643 889 696 785 900 566 539 24 316 573 300 538 65 8…
Output: 7283

Example 3:

Input: 1237 597 472 99 126 750 311 900 523 299 617 539 240 727 379 536 403 252 255 106 385 507 34 328 611 788 204 125 363 617 600 35 920 782 588 212 553 1 200 491 931 734 28 553 751 983 427 915 92 9 693 271 951 408 109 724 266 918 80 944 335 111 334 183 216 639 430 611 15 122 123 138 511 673 209 204 303 776 54 314 65 296 348 33 755 69 399 978 565 865 671 532 981 6 280 989 33 685 720 940 13 913 883 300 395 480 722 930 161 559 155 728 301 210 441 787 40 937 394 322 334 102 674 65 14 254 95 310 93 568 405 999 638 493 787 973 913 944 184 151 935 603 460 504 150 982 741 213 566 795 126 5 112 41 167 310 869 743 907 199 820 325 980 748 53 76 963 57 314 596 150 53 369 714 819 437 915 451 236 675 611 209 208 836 311 910 292 998 474 118 633 566 560 913 825 470 298 164 535 955 218 85 789 843 817 431 270 398…
Output: 157216

Constraints:

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

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