CT36570

The windows Frugal Pairs Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Legend says the vault under the steppe camp of Horselord Plains opens only for a perfect tally of windows. Eklavya means to find out. 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 <= 2228; 1 <= a[i],k <= 1000000.

Example 1:

Input: 593 1043740 793362 237188 58058 647588 90738 177861 877204 705919 833214 524609 370363 209577 40074 45108 25344 133948 832476 383245 361153 974846 300652 511613 440610 652527 453388 536931 310702 652814 769753 282881 121809 31778 286806 375454 327827 668887 38002 244326 178779 700146 839788 12904 438866 454625 969599 577655 420261 65944 42658 277675 290907 787570 996532 371341 251909 219422 984965 542018 749222 376687 357189 85673 542090 219742 898208 696084 37957 172672 860759 179408 495188 881826 831383 381409 358977 197687 631695 267592 89913 59424 520289 115714 635793 107470 150636 434989 534529 940789 925857 800728 217332 446610 98251 952801 298987 221256 848691 332728 506504 569479 766627 759911 792933 284886 952258 946305 611280 3633 166607 499254 65206 332670 769883 483110 646342 5…
Output: 95057

Example 2:

Input: 1590 1950225 975214 920308 257345 129785 38502 371850 846049 665753 600552 762848 206215 133813 916119 426859 373715 647598 106684 489432 594090 47197 247451 250883 904820 161398 303287 614986 88125 665508 624818 948810 453963 94009 383133 391647 152255 186315 677924 427595 520423 148447 927561 574688 334565 556204 453084 243235 920083 421572 871675 974834 214090 805868 932656 110732 999079 386254 535646 644121 262848 438532 481090 157452 256137 426719 865320 225790 189914 403988 636960 821748 233976 826900 759362 202304 296167 170472 27829 399089 991702 234068 117014 142439 29924 460344 919721 304889 126346 679036 206090 714983 33082 498979 524863 286588 518383 928789 883163 719362 830883 67450 135369 946971 78794 622802 210743 914275 700463 106065 117312 85259 694025 660179 729599 844781…
Output: 1261943

Example 3:

Input: 409 105675 374924 850804 411384 547409 153507 598237 884348 825026 525336 278384 342274 544514 408314 68431 580865 787229 167883 69014 928807 228008 832042 982656 938266 754656 309138 809529 14682 152305 178856 852329 764105 704415 861898 795176 567135 774481 514156 962368 820700 254903 869525 577098 793412 851991 185776 65498 443738 46322 85558 42397 840295 985810 330080 931064 728036 100158 566579 928835 84975 99906 699092 184063 518565 945847 934425 103687 815481 459211 873611 804505 802486 359438 918067 245194 174539 793404 124405 944285 61559 287675 303228 963390 936637 176452 262360 939185 751254 406916 216675 578511 324513 706626 369916 27582 200390 439430 797009 132038 661288 781751 787610 803764 764307 755051 883204 954112 517346 963879 796070 832981 7146 920054 669700 984942 5312…
Output: 468

Constraints:

2 <= n <= 2228; 1 <= a[i],k <= 1000000.

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