CT45079

Gail's Frugal Pairs Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The harbor bell rings at the savanna camp of Amberplain; Gail weighs the day's windows 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 <= 3726; 1 <= a[i],k <= 1000000.

Example 1:

Input: 3655 1189039 73154 17838 201096 552388 741709 383332 124423 579321 9362 806033 810918 553244 726209 751111 12451 456483 141752 583475 181243 558745 515740 59712 820919 616747 956739 424131 276948 949008 942276 663815 677223 813443 100515 660686 363366 930803 588537 379787 576367 898894 507317 927681 702998 424022 843182 494020 101578 346100 32769 765468 187593 863726 988194 822044 246655 53027 934410 499911 616199 961024 601608 412193 121961 364953 600133 809255 657224 392917 396847 603030 128026 841555 306877 483293 575873 35205 582078 789538 674916 840624 243262 228189 598964 710612 387846 374152 639215 995935 549346 579205 743804 413516 328184 321392 305259 509249 862199 344154 740468 542990 190309 596317 932373 808354 225884 428685 230671 661207 792417 273977 748359 789962 514485 38717…
Output: 4443932

Example 2:

Input: 1662 303490 837494 156564 734444 980496 274785 793738 685136 50185 859983 979737 845440 968263 230651 103070 612806 622269 290036 269 921277 531969 600461 850878 850313 471956 843224 319643 125470 562075 656449 26895 375772 851050 614894 570837 674768 794729 778271 460301 372643 50606 121327 408390 459583 461162 218974 942915 644565 166269 574278 740233 392806 556289 966407 427468 468721 38044 214681 746626 864736 923185 365632 111510 743605 825535 963600 857537 13085 88480 43071 749731 478261 101814 554641 737537 224115 231270 294888 890762 948763 32129 444381 717590 212271 905937 664824 917999 512243 85836 994001 257923 31304 298606 379774 752795 657984 139518 261008 730487 616069 464144 400782 799568 829891 549813 905089 520450 365223 202611 306426 555842 31080 248229 127407 179691 5404…
Output: 66610

Example 3:

Input: 3580 1440318 252824 418549 106557 893618 373642 164142 320771 598374 314244 522275 824246 258226 400337 280964 564082 820007 287560 84918 528551 356358 54700 608273 244946 609502 721684 934341 974593 193532 736506 999229 639763 144880 548827 765007 360805 400305 721777 538199 343792 970901 492896 233223 124371 341287 542714 583261 75012 993250 178976 895273 513087 7594 705613 579056 106159 526408 391112 258443 473375 246957 619435 385383 752041 523856 338466 605549 569789 140 225952 443320 665649 783878 267173 169932 917132 831123 172594 879072 879245 417251 607524 923979 497086 277068 146095 108050 26283 850558 982554 214081 762205 463402 665014 35435 2831 179187 748680 198858 606973 396503 741420 167598 930189 989834 364522 75803 125091 746620 828900 166497 773497 931390 198763 442340 43…
Output: 5371951

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gail's Frugal Pairs Ledger - MEDIUM Coding Problem | CodeTikki