CT30734

The Vineward Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the ivy courts of Vineward pays by the answer, and Warden intends to earn it. First: the full register of scrolls. 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 <= 1060; 0 <= a[i],k <= 1000000.

Example 1:

Input: 823 662108 696545 317610 710829 135290 668122 860933 778650 545076 721939 76787 934715 248312 212926 521585 825234 765015 48453 191581 525493 674589 361318 649158 975116 297977 765144 350872 587742 993142 478218 856223 251635 674873 668623 54244 859758 212418 142185 751703 163831 84815 979864 104783 726580 315585 201058 925861 476517 947904 962048 726158 431214 721098 933754 992178 855764 322944 696934 769309 898258 793470 132181 821323 472889 717645 542971 575293 880768 726177 128530 346509 882989 884512 576337 302214 968315 97553 607605 497191 516741 355359 192821 135949 319963 965025 269184 519980 243135 56970 383498 419105 647785 634425 958091 888584 367939 514615 225037 751556 804160 697371 128876 438755 128597 24116 684381 729842 234135 132343 690706 58934 299122 644903 589139 867002…
Output: 72138

Example 2:

Input: 576 1369745 142745 931406 626543 436192 532803 716150 148635 54226 13070 558501 123614 618884 262112 655544 492983 946165 609852 555530 202536 643748 464070 696382 999860 685891 927553 242727 194427 474797 381195 643292 102212 47009 55257 805181 41532 88947 905419 829351 481018 118504 477076 260715 208397 234294 94089 222939 724945 401163 722094 275939 275748 301186 41888 828403 786798 603604 790249 202895 203604 589588 93664 718343 568926 949890 955697 173822 578336 795270 183205 685764 83859 204676 609479 307134 495805 687350 651590 617924 250571 536758 2349 208026 508095 356013 828638 517714 216507 560827 832926 280404 732235 832809 216187 764700 719194 108288 269817 147003 20934 43464 270946 641580 598038 990256 165738 561141 808353 212026 589210 668473 964681 234647 168237 995892 7283…
Output: 136139

Example 3:

Input: 87 1556561 322550 639047 761962 342396 76904 295921 409538 387194 412605 876083 729109 267016 999893 650223 742609 202012 445251 448533 491188 951412 772463 870331 598313 271816 38078 746912 817565 292528 714790 380907 824009 587168 15360 720033 484790 46914 76403 378643 110779 498084 89507 588988 100886 814006 638270 89196 150571 960579 589235 690279 3136 251389 672978 750896 979526 492823 443052 474926 847470 912332 758574 989391 71135 404316 150108 26425 620430 375077 12773 721258 141920 369592 381154 245639 711557 782578 272968 417385 771138 380932 172737 67419 658237 407866 823014 431904 305140
Output: 3460

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Vineward Frugal Pairs - MEDIUM Coding Problem | CodeTikki