CT31217

The Frugal Pairs at Ironvein

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the mining town of Ironvein pays by the answer, and Quinn intends to earn it. First: the full register of ribbons. 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 <= 3262; 0 <= a[i],k <= 1000000.

Example 1:

Input: 2780 357417 657302 583292 906602 826860 75798 604225 752116 664826 499541 611346 361724 18414 721535 164092 537134 560009 757228 287267 821127 140805 288180 870264 646580 570564 790044 641601 259620 66286 463100 950260 958280 544896 920402 971671 44276 955245 658696 123714 505102 607375 306115 577415 768602 114812 437553 73555 208780 997792 435385 145546 138967 987533 732602 993876 727246 927606 502769 120603 330985 325679 815309 665177 499986 68531 706445 57084 200117 656350 40954 555994 496728 559407 802156 389968 320142 109511 332058 305766 48249 900656 544939 968925 459626 162299 642588 570759 629508 752739 881748 498856 826838 399686 103333 535994 4552 711438 253825 664581 924303 733931 945872 27114 665799 266248 531876 937720 546080 570322 389636 512905 25263 43692 377121 476569 2225…
Output: 247812

Example 2:

Input: 1518 66486 579104 904728 440957 624524 316656 121697 508984 754381 390945 688447 295975 425235 237504 938403 932464 185780 61314 53143 631152 244276 325312 695364 22255 964657 547819 860230 88869 401768 210838 180894 529759 541315 314855 900921 283209 242925 248609 80529 407122 631595 436218 20845 908650 458054 692086 833295 105041 594064 728666 686363 613986 358142 733804 785763 35535 690733 539949 548691 947123 605563 93979 919155 840168 325220 275049 829720 335431 768474 60061 999987 266084 845222 71477 501718 291738 771627 278817 824593 994750 933847 397505 634515 531068 823242 458181 63537 670483 95648 743413 517100 28283 245517 891215 105179 271293 841272 721166 11765 21411 402406 966202 619077 751844 81211 754190 419803 569457 146257 20716 966989 225077 507379 139234 720279 765640 6…
Output: 3369

Example 3:

Input: 801 1624023 199758 350636 584136 989023 28933 36058 773101 980624 568815 793978 627171 758918 682635 239480 809661 346515 393388 253289 81153 553512 972788 101154 710680 970889 678089 169862 488597 123041 616089 552140 156524 785144 466978 58053 612462 529744 175012 677394 552795 866725 714341 824229 562161 890124 126151 450420 257466 569638 826670 210773 457583 392297 720665 453669 713335 243862 650774 274652 323886 667728 202969 661695 628076 413504 290525 387402 201710 449786 335451 523242 46025 758381 391992 936022 966658 95927 31363 687554 278027 493520 570136 345565 318923 591347 819784 316271 258478 122231 141270 647141 162568 102120 863258 656410 401485 223207 57555 238144 591440 732982 663736 900982 416703 11459 593898 389307 672053 599688 228833 779700 98645 712067 76105 659760 8…
Output: 302291

Constraints:

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

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