CT55451

Yara's Starlit scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the smokehouses of Brineport close for winter, Yara must finish the scrolls ledger - one figure at a time. 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 <= 3512; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 2839 946819103 511879584 820370761 665022170 705407253 28647078 532177260 989813152 983566726 716364064 226155105 818341604 124622802 918188307 792154345 939635723 195946962 952430623 928462736 17084677 770501778 213639189 896650409 702564614 562920103 279161120 538036037 788445925 789814656 2951312 663608089 67865235 706196013 413368837 987823280 179842856 141201689 677398638 174434277 673100208 421096958 379505731 451839867 837925373 7511570 72260259 929714265 834084658 748137657 133765981 140229044 759984341 216891923 991632025 933921307 564707671 981936695 137123413 388978687 673224997 669251821 496760389 724256597 46726461 529294104 788645579 378119205 242567843 41711525 185212431 522258664 776029914 194481509 119100655 834629739 340044356 647558701 745515611 261115950 882190259 58069…
Output: 1803791

Example 2:

Input: 2154 1596999059 935800794 476397450 632919123 236158900 895193171 159252763 997598638 35926719 394977930 909389019 203385032 19609546 320510298 542504181 811914046 169062712 464630352 673910356 594813600 654957582 575101340 923525990 907162033 117159792 774279200 294376083 121621359 212473825 570523301 697952163 350782922 498280583 375208381 357520803 651022023 735829853 528461965 612528641 696312472 370290040 735188430 313663819 475401306 91364428 864268930 588842672 919330639 327161931 581037015 637272556 689559215 121367255 134622177 891293690 809933556 710759643 315508602 951726091 514808769 164309379 808461548 130089390 211338191 456147281 374024012 8265044 206439633 268139267 761435343 260893597 65331821 957330379 517909571 196138269 610176236 712102373 877701180 282041661 154570601 …
Output: 2133136

Example 3:

Input: 2105 1870398000 786926731 390643106 714526647 800083070 216378796 460896093 570230498 483174721 196888459 596295328 408519496 839129959 397487343 647910145 704891191 42599502 239609730 318950731 6088909 853519300 148981107 528499580 551671378 200929442 564743491 876549262 292769604 558794328 433474865 924529319 138184501 695049851 24058013 955631428 109908179 616353716 560708907 257073776 206626690 58017864 121360929 922786011 167681716 701056500 144869847 228591625 987739459 212580926 198398978 890613628 640577029 643141521 811278865 637739457 815695115 660740872 119704436 308350446 230939388 713748753 182178077 789549431 936378507 623957386 109411231 898148155 904531618 42086921 342969841 84431153 711349767 921855101 283636441 438749222 599201526 314016053 798730845 59230353 630538821 61…
Output: 2197401

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Yara's Starlit scrolls - MEDIUM Coding Problem | CodeTikki