CT33063

The Frugal Pairs Beneath Whitewick

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the cotton rows of Whitewick with crates of segments, and Jaya the inventory keeper must account for every last one. 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 <= 2926; 1 <= a[i],k <= 1000.

Example 1:

Input: 670 1819 717 446 343 236 110 176 617 656 136 209 588 677 386 940 217 777 933 949 634 706 663 761 365 273 326 262 354 655 30 883 815 163 98 279 517 800 345 730 249 113 945 665 351 17 957 561 823 967 577 675 85 509 785 433 382 929 34 187 763 904 447 804 18 145 828 643 138 880 387 160 970 482 957 224 413 242 228 432 591 881 487 942 916 792 289 734 206 706 516 925 77 388 934 269 79 825 807 760 357 480 380 673 730 796 520 795 855 976 405 285 103 130 783 158 452 134 883 658 424 9 266 418 172 496 823 23 9 197 227 535 806 822 153 803 117 663 573 940 656 463 628 878 852 528 569 746 6 455 551 641 635 432 432 900 224 205 254 716 495 983 172 649 157 210 520 587 140 290 284 935 436 496 615 906 237 744 8 662 356 537 894 634 84 179 842 119 836 121 991 106 774 35 224 716 740 374 671 734 389 557 372 392 28…
Output: 220560

Example 2:

Input: 648 464 211 170 505 544 206 891 982 888 255 316 767 977 450 768 620 875 528 156 421 719 157 372 785 293 129 651 619 302 35 36 117 803 458 527 472 576 980 537 87 840 574 717 203 43 314 1000 1 4 317 678 373 797 899 926 564 26 313 323 104 185 10 688 544 318 428 166 238 123 694 831 141 829 423 494 766 922 677 406 307 316 563 212 439 704 813 668 604 121 216 929 327 495 291 163 287 43 640 940 106 838 559 371 409 588 416 83 579 100 455 19 595 421 494 78 363 980 279 420 59 922 35 968 402 48 781 715 78 226 641 508 967 540 537 529 215 736 645 984 605 764 136 642 258 89 408 166 821 230 575 584 322 575 912 405 295 629 196 460 453 973 332 991 775 776 453 53 204 399 612 907 615 783 822 429 466 388 303 50 819 129 534 97 206 677 22 281 302 532 664 171 18 653 516 885 277 897 227 882 628 813 669 578 561 715…
Output: 22187

Example 3:

Input: 1796 1292 962 104 564 353 921 297 762 568 686 227 681 811 801 372 414 902 550 865 160 216 701 84 632 925 528 800 141 473 49 229 498 833 103 521 703 700 4 480 284 30 83 9 120 409 561 179 686 34 512 818 166 19 837 587 308 7 105 746 403 582 666 684 115 409 152 283 604 28 400 401 602 243 308 73 914 700 124 246 225 387 209 959 60 479 56 430 248 848 39 143 580 21 550 318 672 836 529 661 391 250 679 955 571 634 918 315 502 460 733 599 956 770 586 471 154 993 283 796 257 656 917 484 200 32 731 217 50 146 840 384 757 375 330 948 713 929 885 409 768 261 752 650 959 206 821 509 976 970 983 975 361 680 704 416 887 121 999 121 61 481 609 607 719 601 99 444 592 370 632 57 350 392 864 608 359 208 907 756 28 726 332 150 370 720 774 333 68 540 794 734 820 126 861 188 475 127 90 238 142 638 694 168 278 553 …
Output: 1193355

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Frugal Pairs Beneath Whitewick - MEDIUM Coding Problem | CodeTikki