CT44475

Rekha's Brass stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Rekha inherited the foundry at the copper works of Verdigris along with its curious bookkeeping system for stretches. 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 <= 3297; 0 <= a[i],k <= 1000.

Example 1:

Input: 2199 1966 57 667 886 344 894 805 661 592 5 711 439 381 846 946 478 636 698 992 198 249 521 460 278 183 361 683 279 956 828 744 764 548 400 284 923 491 790 890 175 966 562 323 38 761 982 609 795 964 897 486 362 518 232 633 430 163 680 383 36 717 847 372 450 749 825 77 715 698 639 767 834 682 685 282 895 847 945 558 214 245 209 84 32 913 295 4 925 742 984 752 235 328 858 389 360 382 858 559 858 121 738 997 508 747 279 238 943 673 549 649 313 688 26 683 628 665 749 966 367 282 571 403 324 712 326 743 471 633 662 655 691 321 235 500 15 221 64 84 157 720 751 598 721 321 839 483 881 202 945 951 930 759 44 495 216 353 880 848 823 788 809 148 933 363 743 473 166 155 785 86 17 281 451 148 73 633 779 974 182 907 487 797 397 826 776 509 295 900 560 347 23 262 196 239 661 257 231 165 294 603 432 227 1…
Output: 2414371

Example 2:

Input: 2963 528 134 289 158 440 468 385 447 115 343 45 488 15 526 98 123 878 443 941 39 545 305 482 130 967 266 82 962 140 635 344 894 503 374 807 512 431 900 472 126 220 734 595 479 455 635 6 384 416 33 647 905 146 394 349 230 168 189 149 586 390 448 422 387 106 378 267 649 33 131 840 791 22 918 819 633 981 390 225 897 695 913 83 840 636 464 402 422 851 98 770 570 666 122 181 802 120 705 148 597 567 8 496 558 499 748 152 164 659 249 271 752 354 410 695 336 637 467 422 368 957 299 824 469 399 541 637 682 401 81 808 779 78 357 89 604 478 679 895 436 343 563 776 508 164 127 998 392 856 721 617 89 144 410 910 297 229 720 562 244 923 216 995 528 643 482 777 161 38 922 514 475 663 379 130 907 489 524 240 585 94 690 375 417 251 448 550 202 176 37 841 323 125 879 713 373 165 147 589 752 666 754 653 698 …
Output: 586608

Example 3:

Input: 3056 226 452 820 823 627 815 819 54 596 228 785 398 550 133 95 7 318 25 534 403 862 598 237 853 308 771 815 139 976 427 461 556 146 397 846 850 179 143 792 420 492 428 439 56 507 57 832 227 255 750 453 697 216 822 378 132 892 572 947 590 127 249 455 510 118 205 644 941 287 576 888 484 464 318 459 615 681 124 570 614 951 594 909 911 519 782 719 24 544 397 638 212 132 148 566 379 2 801 845 517 380 809 431 621 175 882 941 105 20 398 180 565 23 124 981 411 768 708 732 604 734 515 442 898 930 623 119 23 37 539 15 932 3 596 48 890 375 934 971 418 888 529 523 787 358 764 132 25 983 546 274 67 599 699 84 301 786 813 429 852 134 117 788 539 740 790 801 893 725 926 81 56 87 221 913 30 156 716 105 913 455 555 28 627 786 32 347 230 926 536 915 424 276 433 811 266 795 792 45 732 694 80 62 913 723 918 5…
Output: 125774

Constraints:

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

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