CT43129

The Frugal Pairs Beneath Bloomglass

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the orchid house of Bloomglass, Ojas studies rows of windows entries. One clean number will settle the guild's oldest argument. 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 <= 2688; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 787 588095 -301378 -656370 338767 -565695 -529976 738441 -824273 -79260 337060 701583 -48633 782868 229637 978372 586338 -695909 -457707 -835349 48062 -169047 -633641 446490 -282326 484281 -838773 -492590 540849 933641 -679814 -451459 903614 793583 20806 288612 598208 126677 -272283 -412473 -487822 6231 380394 266417 610851 -683606 -712154 -502714 194490 780579 -648689 -388006 500022 445537 -115829 -192641 99327 -232647 941238 939199 -566264 575157 302204 -330116 -51975 60157 193993 168626 -829497 628622 610867 -445385 -808242 -698435 -331342 -47580 -773687 370190 -528275 -573851 -138507 -331184 552285 766780 -548072 -290352 -184362 -187057 311460 -749153 -183646 -767174 903862 604224 -825256 -80186 -139359 796024 791596 -814841 31587 -36525 -226274 -357306 343329 -816384 279238 -481947 -8…
Output: 230192

Example 2:

Input: 2040 1796025 760236 598601 94247 358928 -840155 -106872 -324647 -174835 -35980 719649 378287 486193 -267233 -756358 -667293 115723 708909 490226 841708 -441502 -478839 734542 357268 330644 422080 362713 -58349 529437 -200214 198085 935622 -685079 387861 -409835 834203 954025 200225 -183379 -898516 -46110 728763 184468 479661 -82825 146267 -696328 589315 703247 -404210 -645845 -795482 292200 -340973 -10283 -518462 -370326 498802 -738329 922928 871183 -979454 956853 -57088 -535293 64789 422265 -39731 -109964 -262604 -884222 471777 -345708 567492 434024 -825927 95479 -127913 173605 930101 412934 -955780 783086 376634 -142489 182514 -501340 795862 -138155 62917 -307997 -388072 584304 -756769 549722 182185 -619651 -979535 -569673 245328 547484 651384 -551977 865685 -329455 515779 -703760 323155…
Output: 2066949

Example 3:

Input: 814 208119 -611619 -441746 -627897 -959941 87590 834906 176027 -566854 -516190 -255796 -503895 477243 180880 148878 601063 22526 399914 -113453 -282539 110900 -297944 -339306 -428692 -378738 -933673 931717 831314 46546 726493 -955676 858481 -332594 386318 -703484 602792 916762 464416 -554282 671063 357802 78022 -615717 163580 927862 546635 885961 -371676 821284 169686 -994460 469836 -665531 705554 699167 216920 937404 347385 367511 8368 -339128 194616 609229 -377357 535938 -263612 -30155 353136 632344 -647928 890253 87286 -370769 -840820 -778296 767718 -275062 597273 508699 81413 504437 713877 -132406 601224 587764 -695941 -615821 308662 -9552 -573343 541021 -810712 -220148 845203 -841376 222565 -10667 -105105 404797 190704 259962 -227186 -100518 257640 586616 558853 642183 166600 -380318 …
Output: 199651

Constraints:

2 <= n <= 2688; -1000000 <= a[i],k <= 1000000.

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