CT33364

The Frugal Pairs of the Crimson stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the salt flats of Palemere; Rhys weighs the day's stretches manifests and starts the calculations. 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 <= 1634; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1219 844335 194396 863901 163800 27161 292066 467300 425957 211583 990010 411969 582209 854753 953607 915457 771907 706947 23186 232121 699470 200463 102911 73419 861903 291186 862500 288078 300749 193488 445366 940362 343753 35450 576756 944913 185841 881952 680720 444838 692544 898995 344585 461120 586422 996975 340058 974065 977144 718503 738452 333192 694769 162231 954917 431973 412770 886747 525112 395539 397704 701270 198193 326213 733879 960730 716311 673304 464499 593775 374411 20334 636732 207239 385412 900592 986227 479008 758776 951445 92597 639801 458192 13763 837602 563118 944358 631104 234929 981247 705915 550365 101251 278225 801034 915096 226961 388047 946892 375117 610753 241847 930797 521766 678651 573835 543205 875110 853024 688583 669860 435554 317270 718007 149723 9896…
Output: 264691

Example 2:

Input: 676 1602226 284824 522179 511096 425525 275775 385462 338414 401543 893966 954264 707456 106463 143306 3908 453931 291668 313143 819690 339289 87347 251128 215795 253649 467068 999038 840620 541689 960044 585578 93795 409147 775458 109626 287825 6522 278611 822671 436353 281372 377905 385755 525262 994832 380789 63600 760108 441439 303407 655961 651003 99478 797678 973417 601643 70026 707957 103318 163450 398159 28527 79313 389083 284202 166185 273915 6672 900435 238387 318198 753055 338415 50182 418440 347127 438461 787118 38736 601797 582809 796277 492712 468456 745510 143157 993696 367015 786954 75964 314639 327342 903109 36414 567676 104169 43815 840231 700370 734911 123251 212365 722561 835621 40837 464953 651145 75034 542956 763805 402054 267965 49017 14847 855150 139241 588264 58420…
Output: 212211

Example 3:

Input: 2 335240 483735 167269
Output: 0

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.