CT48232

The Frugal Pairs at Barkhaven

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the cork grove of Barkhaven pays by the answer, and Bhanu intends to earn it. First: the full register of panels. 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 <= 2214; 0 <= a[i],k <= 1000000.

Example 1:

Input: 1235 305357 511849 490322 935455 993340 269118 715732 502702 917150 39421 723077 912912 722610 92569 231925 68681 916024 330289 561201 204913 278495 692620 730201 12658 765730 96642 136187 588186 599402 99957 902003 307882 407264 913669 688494 84974 174705 101579 540544 590715 642347 563686 164729 797797 282519 853108 650117 232771 31942 833706 348262 677976 385969 914115 772629 648687 973153 970489 470368 605417 768463 398687 635390 97524 221018 537813 80566 417015 216656 329263 112857 925272 926543 292213 332012 226905 972186 907551 152000 985550 568125 706089 786734 322089 685638 452385 991460 991282 549791 678025 571300 628158 111837 718032 383422 601223 196927 10997 654563 193893 112759 112708 125571 581458 891741 496775 694808 578205 265758 565056 959303 39909 865964 233941 71772 688…
Output: 33327

Example 2:

Input: 1875 979474 10049 818783 142215 232049 262831 261670 427341 277449 750782 819635 33170 524259 456059 548017 585795 78394 238701 719428 502649 300456 162587 60140 373878 424242 637201 210784 225060 345701 548856 975443 606008 113951 584683 875608 660389 725961 38580 790615 257182 357112 710510 641103 124951 497182 910761 182558 732127 322717 816706 480921 222370 149102 471787 630830 373545 907226 800417 506214 9062 320031 17396 107237 928303 945766 150858 975179 423706 169140 914927 919602 848369 661747 365762 634235 358060 125384 19587 983029 244671 282966 92318 699910 618405 824020 58108 9020 857331 924168 78408 76506 213558 836384 518065 471521 864031 873161 630294 96866 548389 223562 719445 959953 334852 908051 931489 743935 862166 189171 973676 586047 295429 746866 16808 640431 665503 …
Output: 812745

Example 3:

Input: 1974 793425 141425 473562 877220 409034 997298 824835 163860 371961 177380 371515 799948 426939 395598 275454 433641 668698 504610 319462 251459 427703 832913 333643 118515 791880 87704 403141 458418 845683 246682 891320 218357 732642 735385 251991 130724 653203 841775 833792 466016 990923 373780 525308 550911 918727 821074 641182 763468 170106 730701 111118 159188 211988 308635 230839 336568 9958 786964 280250 357879 393925 441534 845458 814767 301092 2491 905448 187125 599734 886772 150756 345520 418861 495804 915361 97012 491279 354187 783615 765648 744855 411506 163647 501009 183627 398776 665036 841264 335591 475651 107213 822171 493074 216983 111006 52995 394207 944828 689605 580632 849294 421134 146261 900704 105466 466005 524019 966794 707972 816387 446184 506345 79892 904077 92871…
Output: 619456

Constraints:

2 <= n <= 2214; 0 <= a[i],k <= 1000000.

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