CT22167

The Pair Tally of the Celestial coins

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the ribbon falls of Cascade Vale, Arjun the registry keeper keeps careful count of the coins. Recover the missing manifest, every figure matters. Task: Read n integers and a target k. Print the number of index pairs (i,j) with i < j such that a[i] + a[j] = k. Input format: First line: n and k. Second line: n space-separated integers. Output format: Print the count of valid pairs. Constraints: 2 <= n <= 2000; -100 <= a[i],k <= 1000.

Example 1:

Input: 1589 1996 205 384 407 825 177 652 573 429 397 597 818 25 549 779 381 859 -95 13 426 307 634 739 807 336 345 356 15 765 316 937 522 176 464 521 649 710 421 378 -44 186 340 147 987 873 953 456 298 612 568 806 135 575 912 283 -91 165 235 761 541 300 12 53 538 907 337 37 302 256 935 856 598 582 584 5 -81 665 485 758 451 321 875 90 602 875 996 514 108 97 -83 536 583 486 518 77 192 173 929 186 967 974 961 -53 840 308 168 315 -94 -66 213 903 633 147 917 148 -19 413 262 457 320 786 307 738 738 990 976 835 769 -33 219 890 270 450 840 206 221 863 603 76 829 130 449 -29 847 989 413 246 348 727 979 857 -4 700 667 -8 539 904 7 645 -37 779 644 788 526 413 878 196 595 -87 299 22 187 118 296 961 -50 664 147 549 582 -64 926 600 261 759 411 614 148 931 874 793 86 823 362 437 591 119 874 854 722 897 286 418 …
Output: 3

Example 2:

Input: 180 137 673 364 -1 797 301 884 823 760 200 298 605 180 905 417 933 -22 274 569 281 1000 868 829 16 195 595 203 678 719 395 403 733 823 873 170 413 905 -54 770 274 198 120 568 241 257 695 5 188 489 792 470 269 161 486 101 194 201 675 418 156 354 774 592 491 681 974 371 91 172 222 253 844 576 689 770 443 -41 -47 -41 693 758 51 749 839 -34 -72 355 546 -65 937 132 472 491 250 91 867 509 979 30 2 498 896 259 989 236 137 491 922 362 56 -39 823 639 170 836 259 749 970 658 681 438 -8 76 26 -96 837 821 609 336 735 531 -81 811 778 912 43 883 279 908 817 207 332 84 244 -30 753 237 -82 288 735 -65 710 414 904 770 -11 18 588 -13 109 593 -75 95 380 135 725 722 829 967 290 988 516 801 692 -29 298 263 246 623 910 450
Output: 2

Example 3:

Input: 769 614 -57 898 767 92 -68 345 602 310 689 949 691 796 -1 520 -66 520 173 978 808 694 -73 331 149 51 217 981 431 842 558 544 331 332 193 326 299 262 77 611 68 699 956 764 895 327 203 35 350 427 -22 223 679 103 191 548 757 467 639 893 333 416 -96 546 659 292 497 571 906 302 513 435 335 156 682 523 859 23 683 -100 174 679 238 952 470 509 87 849 67 925 373 715 530 548 288 602 282 588 21 433 928 531 496 611 780 18 993 -9 830 585 59 28 624 -13 526 224 120 39 193 -35 309 264 279 147 463 569 600 219 -14 920 933 -41 618 596 249 851 180 230 933 911 133 748 258 621 -28 739 949 981 756 961 328 967 -47 501 854 859 833 602 -80 743 116 809 5 938 503 630 456 860 502 705 127 402 27 214 647 896 784 308 -24 343 -45 -34 715 17 -77 306 412 187 870 224 147 637 214 728 554 562 544 371 666 16 116 493 457 461 -37…
Output: 208

Constraints:

2 <= n <= 2000; -100 <= a[i],k <= 1000.

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