CT52506

Last ribbons of Chavi

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the lantern district of Glowfen, Chavi studies rows of ribbons entries. One clean number will settle the guild's oldest argument. 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 <= 3862; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 445 1469013564 554709623 837005507 435392335 75179362 772058990 759762733 337671516 734270124 554984732 866528671 565194552 975316991 976916025 806683158 937445643 152700938 725468960 29746562 806110939 336905796 100298597 759409634 210540664 937516929 973867318 128523161 961582533 213935851 321830599 333551190 564659261 737635571 62930781 994832918 569230654 100028565 586758463 684282351 444094527 85019803 768917283 144991263 262584906 937056131 179879698 337188637 579488800 291836980 87637002 752539193 2457761 565939865 544095433 1185668 67118779 325689912 773426684 445060647 978271260 645971448 716225953 546689689 516028164 705856179 536195443 137443181 43995397 494666229 281731273 150258455 768831163 275239677 250723274 270538633 24587267 299017010 176277417 570775343 25998918 89422193…
Output: 84785

Example 2:

Input: 1460 204497299 327069751 95595649 355340832 38821591 346111089 778388487 423290182 627724779 110766090 233727065 804694409 306260349 926697587 807514015 493975944 808467163 984727234 352141254 381406366 338020729 973680767 625085931 737979877 366809770 57623846 626651914 158101255 913516810 442370490 232687645 372730777 48235661 680510079 425242682 309573559 141673329 377368474 42850495 308999847 78804980 438798231 29045668 932019169 124318411 843011203 882473424 35328691 730299668 158596789 548612926 116033447 736398819 314238203 225162287 915498507 343683607 166615050 226397127 616582666 253342190 209310726 476317721 303791527 382990185 775172652 786676021 815352021 141454748 418314462 823515122 939832600 537556228 673114073 615358708 999037192 651206665 931130499 8675528 789838747 83897…
Output: 23837

Example 3:

Input: 2721 1472432632 880062944 713107707 476021764 668236099 295810821 567485410 308218673 306926430 891517620 982109954 602776334 239671468 718474078 791364883 322567564 688654928 868887809 186710293 627477092 701195777 908942545 199187923 723082795 202214636 444098964 705428394 15008072 14282476 607583387 534842855 149536937 883170610 933993951 67815543 390937932 825384137 644543287 179398691 144225710 33804486 950128453 814853904 557125094 182748774 909775942 877134552 407394539 91648174 599479524 809693956 706479368 67771579 574987612 704778715 291227627 154262236 350697191 868822780 146119197 42966322 157369612 870330995 311088832 962024786 889861792 966432166 127882874 203564212 483923635 196100798 727566468 972579419 330422671 502636406 46819876 690934213 909977965 770277620 273082604 63…
Output: 3173073

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last ribbons of Chavi - MEDIUM Coding Problem | CodeTikki