CT52094

Sara's Vermilion Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the heron rookery of Longlegs as Sara unrolls the day's manifest of ribbons. The tally will decide the next shipment. 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 <= 2091; 0 <= a[i],k <= 1000.

Example 1:

Input: 1175 1866 2 949 286 222 74 86 162 149 671 987 619 279 562 900 354 816 989 629 525 3 867 285 556 435 159 194 810 19 586 984 798 686 62 568 791 875 441 586 296 875 864 372 225 368 270 790 256 276 624 246 549 865 781 375 767 633 564 650 47 116 178 371 788 570 755 302 342 826 198 357 710 142 211 376 393 12 619 22 963 963 497 756 897 951 107 325 386 23 849 597 605 209 890 725 876 158 329 327 692 273 867 864 609 210 577 777 662 48 636 777 954 105 810 655 520 509 550 11 825 332 229 926 568 731 657 288 218 73 882 961 153 481 100 737 348 879 306 547 412 851 656 251 907 792 260 299 101 226 115 420 994 184 299 587 335 164 824 796 406 30 126 836 716 788 75 246 283 316 48 849 920 221 107 804 736 573 137 420 769 516 246 529 175 39 323 817 35 64 673 183 44 243 99 166 804 2 902 607 214 54 343 271 808 319 …
Output: 684728

Example 2:

Input: 1400 1152 869 290 943 693 388 296 528 498 217 548 593 893 323 233 261 104 665 113 684 193 990 770 36 644 109 511 637 742 5 249 468 431 143 72 929 590 767 666 519 598 829 606 270 582 963 157 771 111 473 843 823 76 446 750 992 47 594 0 686 556 624 478 363 862 434 942 97 731 634 836 196 931 776 343 744 119 486 816 141 66 946 992 911 480 762 237 778 539 557 909 548 117 68 220 656 431 261 510 129 967 952 889 935 403 443 760 588 146 52 650 635 818 238 195 674 486 628 124 857 534 745 780 132 518 934 155 178 944 340 715 158 285 210 127 112 399 721 471 799 366 830 707 569 767 677 258 179 337 678 99 389 895 646 239 112 888 818 198 900 466 820 245 716 637 350 324 503 574 212 268 128 157 816 396 489 468 624 743 416 387 877 659 739 313 658 537 527 8 10 298 702 85 645 995 18 634 119 396 746 830 219 149 …
Output: 646395

Example 3:

Input: 1328 1819 630 275 588 131 658 59 472 231 373 720 508 238 446 802 278 214 885 930 814 483 241 868 979 906 1000 268 848 673 576 405 709 236 133 256 986 555 230 947 39 981 967 973 191 647 803 580 439 819 261 389 10 618 681 226 587 605 918 40 639 872 587 529 926 509 87 867 935 693 438 14 100 681 612 429 266 80 614 733 615 693 480 385 396 532 772 864 567 135 152 685 950 929 973 641 378 442 326 435 355 714 845 915 942 56 318 184 642 30 42 583 149 593 868 49 240 352 181 821 534 662 488 767 623 314 732 363 339 529 854 184 918 465 361 578 344 443 512 885 868 308 645 253 454 807 581 425 575 777 790 112 902 980 716 418 313 673 112 906 368 397 166 643 515 120 58 933 242 365 69 438 16 362 600 472 537 293 774 53 486 514 326 281 487 969 203 341 571 50 99 980 687 753 589 559 379 648 181 40 455 793 254 685…
Output: 867662

Constraints:

2 <= n <= 2091; 0 <= a[i],k <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Sara's Vermilion Ledger - MEDIUM Coding Problem | CodeTikki