CT34675

Wheelwright's stretches Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Wheelwright found an old ledger of stretches in the stall attic at the kelp forests of Tangledeep. The margin notes pose a precise question. 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 <= 1029; 0 <= a[i],k <= 1000.

Example 1:

Input: 889 98 418 152 209 801 76 698 840 714 839 833 55 19 64 96 48 323 492 586 79 907 293 845 392 936 684 196 307 487 444 174 472 87 990 80 797 736 880 389 386 17 956 309 307 889 71 571 158 914 1000 646 584 176 281 342 558 255 76 214 288 488 411 574 416 626 545 216 919 812 664 218 898 852 878 431 281 207 562 807 760 499 945 509 476 47 515 286 133 178 503 296 326 662 46 328 44 308 995 909 635 829 774 425 166 18 410 591 754 215 376 540 238 561 805 655 19 742 657 84 814 44 278 514 847 692 291 147 750 138 96 519 181 79 737 487 508 652 630 57 252 501 146 15 324 322 864 799 261 512 89 179 869 646 160 159 670 531 494 840 87 988 87 711 545 193 754 617 48 714 899 689 815 716 352 446 994 716 967 206 799 865 602 757 306 620 411 125 791 243 968 177 172 277 658 907 154 78 591 667 547 259 642 744 118 503 420 …
Output: 1684

Example 2:

Input: 480 1226 320 954 514 187 699 965 294 906 719 356 908 49 353 429 760 129 151 966 983 322 917 523 527 135 499 685 46 95 523 391 143 519 723 659 993 305 890 720 512 417 897 11 797 454 421 222 355 409 25 279 1000 644 533 419 912 528 244 28 545 698 201 50 986 455 510 563 157 778 263 247 811 70 90 145 642 370 947 761 368 548 398 41 760 1000 416 181 128 228 354 41 896 290 24 186 871 257 992 676 112 413 344 983 275 619 954 883 377 328 764 938 826 188 848 878 366 237 142 23 639 708 288 775 665 629 242 618 348 479 296 589 779 908 921 110 505 475 781 857 92 88 340 652 800 28 121 951 378 967 711 581 261 123 685 975 556 550 352 739 406 963 389 799 960 916 596 109 708 104 639 609 315 504 689 705 109 99 34 378 131 227 21 925 513 942 273 96 546 364 772 365 770 908 748 876 314 93 923 98 963 190 713 93 470 …
Output: 78590

Example 3:

Input: 533 1940 522 110 818 368 184 917 714 755 321 489 963 205 622 638 960 192 589 179 382 490 14 67 257 972 255 914 997 661 492 26 945 8 134 804 383 234 609 760 335 840 472 679 258 539 192 979 884 996 998 850 30 541 381 179 708 765 180 759 532 650 245 623 295 593 183 185 959 451 391 299 309 655 885 223 984 773 290 563 509 589 417 836 193 613 292 640 416 687 124 980 771 349 104 506 149 665 595 655 228 728 274 12 837 868 913 894 808 767 728 775 625 843 911 120 889 202 508 491 289 491 375 522 84 641 677 467 94 399 807 189 252 571 95 536 409 247 614 240 179 135 623 173 447 889 105 995 149 310 22 989 438 892 838 767 702 825 780 367 310 796 987 863 963 542 308 44 122 123 320 341 4 375 771 258 529 771 105 242 340 735 686 173 344 758 769 376 104 367 254 942 808 38 298 890 166 929 60 166 981 997 518 66 …
Output: 141332

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Wheelwright's stretches Reckoning - MEDIUM Coding Problem | CodeTikki