CT32199

Quill's Ledger of windows

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Quill runs the lighthouse at the heron rookery of Longlegs. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 1670; 1 <= a[i],k <= 1000.

Example 1:

Input: 1234 492 366 681 637 399 522 180 338 823 643 679 314 596 253 780 536 850 358 304 753 715 811 476 606 503 598 928 198 338 586 348 684 494 423 913 520 30 61 387 415 84 179 544 703 787 412 730 953 696 451 252 8 836 201 923 737 7 694 604 669 296 966 444 204 98 362 43 861 792 112 727 762 85 308 254 416 268 744 720 800 118 692 339 590 53 362 269 332 303 628 801 613 264 546 483 651 806 389 92 578 323 508 807 157 765 730 156 103 258 649 756 715 250 32 989 659 679 182 164 998 574 530 246 991 31 314 550 559 152 509 741 740 638 839 516 384 24 270 211 166 510 466 672 927 105 230 613 259 524 630 918 92 860 614 254 914 586 459 880 622 92 977 903 18 377 465 796 956 452 348 609 456 154 416 162 9 297 969 828 410 85 631 94 110 37 95 772 463 863 864 232 444 578 253 802 567 38 959 887 314 511 9 154 16 370 385…
Output: 95898

Example 2:

Input: 1595 1633 855 355 361 777 113 323 271 273 825 198 714 739 208 152 344 845 525 509 630 770 302 92 790 559 696 581 112 515 494 611 604 68 638 241 721 816 103 745 765 693 621 850 887 501 74 74 248 96 30 595 205 207 772 403 326 253 297 411 579 304 373 249 944 899 553 416 811 404 774 988 673 528 631 218 936 426 408 851 628 258 358 240 856 486 97 525 456 567 117 862 426 676 743 915 188 189 285 435 632 65 461 895 929 102 842 614 412 798 250 416 53 119 310 629 656 191 855 624 768 353 834 741 93 221 738 671 581 77 258 206 251 106 838 12 724 572 452 609 691 692 315 276 601 894 538 239 634 875 881 382 454 779 670 650 127 738 942 615 942 380 271 877 502 908 172 505 25 1 621 164 848 850 630 315 262 601 50 288 8 467 567 63 66 505 972 88 615 227 332 595 759 594 175 438 532 983 111 515 809 76 88 704 120 4…
Output: 1197908

Example 3:

Input: 1587 418 404 954 781 87 950 123 620 418 855 299 545 327 903 72 74 933 656 204 638 951 398 451 373 413 570 793 568 830 212 714 925 494 512 647 444 344 12 552 230 607 674 75 386 462 493 350 961 15 161 391 198 198 557 244 971 541 223 905 977 782 980 261 761 626 161 263 68 380 791 879 370 517 472 987 608 590 823 299 74 598 412 438 9 425 973 466 113 832 607 652 992 526 976 23 294 40 765 66 311 319 280 961 234 182 383 522 41 180 37 953 719 861 530 77 839 950 927 658 118 570 326 616 409 700 458 311 303 222 459 18 20 36 842 240 542 716 821 669 952 628 632 510 357 870 805 981 246 913 433 869 341 197 486 880 882 187 581 878 494 405 243 281 359 453 742 134 931 788 728 521 613 69 618 837 709 164 39 238 909 996 654 237 10 605 133 600 204 963 100 694 523 745 772 192 882 105 786 559 986 400 364 163 38 87…
Output: 114635

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Quill's Ledger of windows - MEDIUM Coding Problem | CodeTikki