CT30449

The Rustwood Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the fox den of Rustwood, Gautam the reckoner keeps careful count of the panels. Recover the missing manifest, every figure matters. 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 <= 1061; 0 <= a[i],k <= 1000000.

Example 1:

Input: 980 1208109 976274 163448 802210 745557 206394 153985 506963 563177 252885 799212 7288 304183 987311 244092 275158 267232 744003 438766 268259 487597 447512 849231 809804 233314 437014 179961 883841 254739 326434 763304 482246 79674 653505 943996 462329 111329 19801 455731 48092 626990 768588 736450 210192 175624 983809 476783 661878 469670 940881 66944 434728 366851 611927 564792 953152 316418 131888 795319 907969 822139 493055 718218 55686 746359 939767 64098 940911 481218 963021 894974 7655 246388 90446 950112 852591 446764 306928 945521 866774 124765 459924 451465 634652 199332 610256 435822 535469 706691 636855 535216 513715 316516 257129 868527 734976 125384 539597 53404 3281 624989 160367 486572 945022 403554 485544 848038 389791 978360 86141 283714 29657 568110 427979 986390 479973…
Output: 319131

Example 2:

Input: 627 912291 37798 143304 450914 234001 819443 842383 807854 846505 205045 544910 714654 667731 63017 461727 654329 211084 157816 520709 948258 877747 30743 72660 778138 809153 923 330473 548013 21877 353029 250116 894661 672648 666565 57086 363549 872351 999969 724186 199445 763014 167515 661968 477348 689249 136888 26820 617098 727456 195143 107544 73689 490606 954016 819504 635522 276841 683458 855772 56651 172136 177860 978008 37177 391525 896875 330673 88563 273855 517173 64118 452146 571473 485140 953064 32208 5160 922388 63479 64116 539314 394148 314414 217210 560271 220184 181734 31877 861541 541508 966640 722587 947219 359091 894155 215471 160079 650488 279515 954130 248380 300312 749873 632436 570299 479099 70998 342554 225078 797086 2888 861244 722045 954752 248000 18374 326043 88…
Output: 80810

Example 3:

Input: 197 420033 169403 16438 154259 518451 366371 603171 148243 684871 731096 304358 99249 249605 618704 545002 120306 681727 618579 511848 929891 879819 813644 90865 358570 335439 993301 217849 990514 239867 639827 181104 784628 920764 530160 627169 211956 769387 870493 142985 482518 895940 218988 288184 383453 648829 982699 386571 159155 713121 521862 599458 290989 64716 183363 514222 397285 566023 432632 729332 405581 3422 448984 680736 807942 773187 911690 779567 794420 928486 208866 87695 217506 491941 793025 487418 174227 371364 584144 338751 817037 119899 428364 780219 288232 675141 868898 468423 350263 132574 972003 75151 908303 365968 406003 421218 753143 14170 919507 820799 532911 908225 289571 149383 665188 912688 284753 44962 405618 611026 583838 540730 424830 728958 468797 563973 9…
Output: 1328

Constraints:

2 <= n <= 1061; 0 <= a[i],k <= 1000000.

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