CT29799

Wheelwright's Frugal Pairs Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the herring shoals of Silverfin pays by the answer, and Wheelwright 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 <= 3715; 0 <= a[i],k <= 1000000.

Example 1:

Input: 844 830112 151603 104372 502863 400525 718778 811011 425050 873410 405208 26646 110252 985680 617856 174609 419374 481355 112512 880230 293594 299678 128501 10964 893461 930509 966336 546862 266971 789836 972744 916115 23242 473882 535646 193219 267556 735041 708636 695051 72417 204864 427040 436886 308962 643304 346078 211834 218062 682188 917615 356709 766024 157508 845376 274749 849336 919940 982862 298306 611704 900882 53808 904337 183634 839008 10884 300000 550129 343608 304209 483451 854205 494237 599015 254463 228705 372879 969818 550056 384900 646572 151310 389076 685690 185065 448647 769020 280571 141448 855318 594070 552059 864050 643488 949834 290100 723713 908761 427775 920409 942308 284316 350188 490548 674986 538443 603881 843461 529231 845919 583870 354122 23632 680803 28633…
Output: 120853

Example 2:

Input: 3211 958077 617290 433864 864021 38702 104754 576939 289401 430036 25617 351003 416010 938116 76957 92137 727074 51231 622889 129273 380765 237710 847376 99328 576189 258094 418636 31018 779865 989079 408655 537796 983855 848347 913645 542588 617082 537844 32737 825679 569462 894976 547564 454179 95774 978775 741775 778887 227957 750886 832008 915569 551002 925592 837885 745723 654531 364468 121268 765187 598621 879742 340605 704450 721134 919146 239258 600751 235023 105880 157816 272459 333132 340238 964497 433504 593941 738283 194054 90168 546776 685760 563828 408913 341675 27983 239490 722862 934689 744790 269668 404541 696491 147183 723386 587418 940745 706944 866238 927814 374176 243413 618105 484206 7541 287193 199685 367477 398439 711122 556145 646381 821228 511359 45177 706998 1064…
Output: 2458033

Example 3:

Input: 2520 458260 736624 668573 190595 750035 433722 207619 55192 150824 799540 217417 292471 753430 503853 406435 631354 127622 941366 755899 267072 67481 392187 446734 515275 95228 893013 930053 35020 745332 215002 15129 166048 655734 865591 416831 615483 490287 60476 675236 269946 320249 833356 800375 611668 579675 734702 903550 855677 910940 944913 431651 197762 754029 8417 281515 115248 179491 552926 588896 454171 622042 242037 560578 500811 744367 660155 848811 64379 969262 378969 553636 561300 886336 654137 339739 732929 186508 286664 494461 46057 617288 240572 817041 810794 364935 949698 504318 235660 439553 535429 907832 138957 630562 409713 490100 628966 90056 742490 269528 237501 669992 43255 978325 594052 205854 495968 900199 601389 38027 287531 961235 556557 317132 221669 898280 559…
Output: 299256

Constraints:

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

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