CT31636

Maya's panels Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Maya inherited the lighthouse at the caldera rim of Firewatch along with its curious bookkeeping system for panels. Time to make sense of it. 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 <= 2120; 1 <= a[i],k <= 1000.

Example 1:

Input: 1043 406 529 996 833 930 511 596 92 143 794 628 979 74 454 677 118 543 413 171 96 514 357 393 33 193 894 661 913 38 337 853 349 830 538 318 743 678 2 709 571 821 350 516 671 160 165 396 38 939 440 843 193 495 310 292 141 142 67 614 668 924 760 239 973 685 797 569 822 634 578 984 182 81 522 507 726 656 612 451 281 856 527 500 210 103 845 93 647 951 45 578 277 502 396 229 82 557 601 495 129 350 228 521 478 143 237 823 280 297 914 306 192 413 224 639 28 847 745 259 561 45 378 599 637 687 256 29 400 301 635 620 338 126 414 619 851 580 649 169 141 540 206 34 377 319 815 123 670 639 59 890 397 430 650 686 895 755 739 147 711 871 485 579 588 332 817 429 168 305 308 733 603 984 774 11 259 216 399 479 324 846 107 384 221 465 442 834 735 988 970 432 262 595 32 572 984 360 184 975 850 435 656 364 91 …
Output: 41263

Example 2:

Input: 867 812 633 495 191 289 123 132 496 346 76 201 6 885 806 219 745 242 814 208 485 91 776 43 531 670 936 854 559 375 262 973 795 377 290 541 575 879 197 211 79 859 617 700 221 263 417 219 180 369 188 652 248 744 888 334 476 478 22 945 683 66 774 124 376 210 494 230 545 411 852 163 631 233 500 617 293 893 858 511 189 193 39 729 371 366 781 787 874 680 772 812 139 93 580 680 457 31 130 653 353 661 364 620 206 571 405 254 427 449 484 577 13 136 19 130 745 885 950 820 800 365 346 906 344 656 769 483 390 652 803 656 675 48 243 847 139 494 732 764 989 605 177 773 605 301 851 341 183 63 896 24 634 789 739 827 981 735 349 292 931 320 46 851 754 451 630 783 838 919 965 369 466 696 311 196 345 262 745 307 811 248 9 139 527 793 169 841 582 581 979 767 719 786 577 257 360 832 723 105 501 700 621 989 888…
Output: 129239

Example 3:

Input: 994 1740 855 453 582 78 518 18 880 164 589 258 28 690 345 984 58 515 3 822 716 588 189 562 985 406 275 95 763 964 509 364 220 900 145 552 955 653 469 708 93 30 715 787 340 814 566 483 659 520 131 403 652 605 183 959 899 962 222 679 505 79 890 836 115 535 577 875 245 116 350 859 433 357 807 858 337 225 741 918 22 670 938 627 19 758 2 812 663 171 268 598 87 222 87 147 547 456 214 592 904 466 714 86 783 954 285 256 922 698 353 584 681 348 78 212 699 453 822 298 315 106 247 63 548 604 312 297 451 636 530 415 376 186 754 542 800 718 39 103 163 313 671 843 280 151 961 633 74 503 624 783 985 702 946 952 96 237 730 848 285 21 623 40 826 524 766 726 43 237 723 164 645 103 877 551 683 903 779 44 460 464 961 12 727 615 196 660 409 303 899 375 758 895 280 545 161 232 168 305 871 193 258 13 191 233 371…
Output: 479226

Constraints:

2 <= n <= 2120; 1 <= a[i],k <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Maya's panels Frugal Pairs - MEDIUM Coding Problem | CodeTikki