CT40308

Lakshya Counts the segments

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the dune sea of Caravanrest pays by the answer, and Lakshya intends to earn it. First: the full register of segments. 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 <= 1659; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 762 -889966 699798 23353 32917 129109 -574251 691151 323300 -692550 -261802 882643 -933193 -575083 -268847 -190372 -233489 -628580 543200 -522599 -470537 -135874 735129 -303623 -898152 685702 -149932 525303 -588384 379402 499300 194675 410996 -469652 -929755 -842251 -981735 -562160 763241 799309 -294338 -854998 110384 167950 270273 -772592 311243 -463682 -188706 -835013 62527 -914844 -425402 106076 51433 -20232 440739 975522 -578757 938487 99462 955404 705948 -496692 326965 415291 156598 698987 88561 -841772 660290 -112013 -57708 -45424 54748 -240961 964900 814229 385654 -643410 -622250 -972031 -528101 448805 979184 -980485 886880 687877 974340 -665307 -866517 821363 -227788 -608378 585681 133329 -9931 869239 -549753 504120 -543082 285703 623885 -276507 405116 524122 -686793 5678 -357495 1…
Output: 44290

Example 2:

Input: 1077 393911 719656 -806692 -574590 544359 -69818 81033 -762092 -997136 -415965 833808 77019 -728323 738066 267090 -368935 781549 750402 -96082 -610521 -558058 -924676 -931771 669730 311190 499816 -432212 175084 7091 -514592 -749933 -221143 -256945 -357484 -736746 -71345 972418 342017 -189356 405275 -598088 -848512 -239094 -442550 379668 -642794 -553897 -110039 470934 -953616 -92306 786094 -745641 -892696 337150 343332 454157 -841480 -15429 29641 -87256 -934524 829820 -232551 727042 65350 -931347 204671 785453 -662794 52065 -126080 607049 722902 -678644 130001 -711039 199859 932486 -836429 845020 590040 211629 969709 -901903 -135585 -10136 -773286 -95347 -944436 791092 -737415 -393893 594943 -651067 -610890 -408491 -601936 970094 99412 -996329 652308 -60038 837334 848656 -654079 -249100 -68…
Output: 396653

Example 3:

Input: 381 19145 -614125 -597092 -425093 487586 232003 -755559 794226 387245 -146516 864567 324584 -692429 -153192 217056 -475789 -178170 -106707 158265 129929 -739009 858440 -715803 346728 602838 224952 182433 713553 597273 790152 723346 954330 37783 8346 -982104 628103 642397 37448 298858 719737 -63290 -393804 -467773 890324 712525 730950 239352 591866 869334 802888 -222635 -560679 288654 -237124 384597 -929460 21545 202680 824499 -665344 -190317 542696 777121 -801326 710361 770858 638199 836450 -344066 516486 -839230 -51611 49217 291757 681747 -439622 -724136 -480171 803949 469159 -131392 -964476 433566 -177505 563284 -347886 545919 -863698 -306328 184203 361070 -138158 408063 -368767 262734 -198504 569476 -200591 -646242 -736807 585305 566898 956895 87127 752047 -240521 -585936 903127 -952810…
Output: 34908

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Lakshya Counts the segments - MEDIUM Coding Problem | CodeTikki