CT35469

Zaid's Ledger of stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the wren hedges of Thimblewick pays by the answer, and Zaid intends to earn it. First: the full register of stretches. 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 <= 2694; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 2114 1556843346 78040343 902324842 834797995 141814369 364497588 733171065 463042024 150301264 513049878 390272480 361248559 614352329 439809562 203719134 980786922 179005262 159412074 257148145 737351148 463029447 209762778 852086041 665811543 43439702 587684311 485233308 696057056 991194989 267457828 369643438 871310506 679375731 874235296 795981994 898213413 361157658 25317965 438937875 934139578 442259480 832600963 241436080 122099697 979798717 624104215 65274108 427399257 482757923 369077723 544812288 944755909 567608621 417537010 625289120 498109745 815612958 28892810 717557474 350943889 591922995 830923430 751357196 759137080 486068318 901845328 871992227 729480674 520319887 365682754 377072884 656059091 698616945 759207267 671350981 620794536 274913578 850736192 335144193 453611884…
Output: 2007888

Example 2:

Input: 2594 1055513870 14143809 183599894 263290431 33362645 284078285 625209262 860642170 956149915 832227060 392127102 539229928 655217487 490627803 530391031 815671136 125750079 833182158 775577913 512083540 602259529 807049335 133817748 921716743 318039253 453267508 503281718 501689980 72391513 315085871 930014896 549104040 845658107 607800741 206721156 28621496 780002641 328296644 199827362 372648918 241924484 208028073 438517179 229943265 167871972 668931395 95199777 199960748 512476556 151043482 792078311 168858120 186727112 359244822 271904606 497368174 864283627 612525774 704897985 156527455 111258185 796507317 283201706 490773815 230125995 412553359 387422734 879771470 724302688 217935017 868263875 751593199 246780403 965346981 293941492 845389393 910338234 942065120 36753642 136970932 …
Output: 1817306

Example 3:

Input: 1746 1084744960 228348470 678966165 445986407 163747555 186005652 134735917 721261841 204669380 352823867 820001607 866446936 336140505 923420732 662457986 868856039 994683158 551722786 372757692 818871766 520118459 835979280 771043602 428140790 977444075 505596363 515063538 574117990 302994490 85276175 168730323 883651934 652603121 342585703 885563405 93485041 621016790 774117293 561078085 174732464 254287405 238571485 534711602 426697777 457444594 809830136 519787788 182023446 519813536 227543644 90683598 725184299 244279083 936964603 512310791 675045193 86512603 331205425 938391633 603907842 271325271 939346834 805130203 555514521 513852823 31417745 489713479 143045202 242391811 267763248 185245337 562702085 633401350 887235667 655219837 104362356 515630889 156697280 577547902 100281898…
Output: 894738

Constraints:

2 <= n <= 2694; 1 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Zaid's Ledger of stretches - MEDIUM Coding Problem | CodeTikki