CT30499

Theron's Polished Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the willow walks of Reedmarsh, someone must publish the quarterly findings. This year the task falls to Theron, armed only with the ribbons register. 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 <= 2334; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 1038 395256806 969420340 690603167 22372869 4918713 131101124 692883595 757918767 439427670 557591547 507399648 432877862 809265018 927091552 737827483 296813352 478393915 17528992 187987858 268610104 685585096 677269123 526905265 508963172 698063988 45941666 36335418 34013082 786151026 495477934 477643432 652126622 963512478 960051063 724915548 422924000 611949151 299193880 939505275 864646659 325772362 997378106 171893726 517477063 596028142 899421895 806542599 980476315 993100960 609301987 430220523 483042689 415066661 930585736 66295962 791937555 827145632 315796313 250122911 384064867 564315570 129997303 187795954 368457763 575894693 638834349 723357719 508992382 587229286 967731185 452829273 671550465 638112203 752987294 822203664 351482423 940071624 879830594 917454227 315894592 334…
Output: 39627

Example 2:

Input: 100 456739001 731906557 957483462 318745032 700000695 653431455 170161366 924570934 962683027 200241204 448446606 922720439 827616041 253967395 278888915 162358292 160927769 749951464 423679953 410869898 818211954 135835261 456043910 866475957 289287013 680116646 651872991 44846291 278909683 601821200 625815903 278845103 831488847 24075427 628623811 448707894 199746855 201702804 21517352 690657065 906478685 827790315 675201427 319056746 228737452 293236561 12324150 853325482 66237668 442171932 360890546 477997030 156950184 829689573 493691667 325921639 54969110 623671655 343955053 952370639 503070364 197962177 476447992 37801090 982279431 509075276 201848001 623649809 595666608 669139733 617086491 233223194 512810443 495329804 470975582 466820271 315062880 203797062 824897497 334490748 634…
Output: 521

Example 3:

Input: 537 1695446201 516390861 582635487 805087532 589892700 231495446 511719796 96749715 556914584 310485250 353894145 81312977 253087078 127443394 935348922 435702290 280628610 697790353 834187605 160519476 940601532 724797264 19808719 360789925 74073870 938660969 731790970 31069194 397450462 104727058 955824272 793126217 841277498 491395705 566568977 719037704 968438789 855010623 789720237 118415454 394544274 137427614 226607728 61145862 178395499 968944799 641232381 843243497 899994344 897234701 695924195 255664709 876355955 502473580 362918868 490250282 936817096 208436451 403994378 806820732 574712047 704442469 461759856 150127464 913559610 330936400 804361718 560437564 427792849 318096529 286727938 938220337 118188677 741663056 550917935 837525074 890310731 165920116 655918246 519361821 9…
Output: 135816

Constraints:

2 <= n <= 2334; -1000000 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Theron's Polished Ledger - MEDIUM Coding Problem | CodeTikki