CT29258

Dev Counts the scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the indigo vats of Bluehollow, Dev the accountant keeps careful count of the scrolls. balance the workshop's books, every figure matters. 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 <= 3453; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 2279 -100537 -216300 971069 -320047 862868 -219395 871320 120258 126251 853388 -140856 -540092 322557 -518162 276359 848583 711130 -124281 -959381 -796573 -140632 814087 59913 442792 -139812 -939116 -999031 502098 915093 -536497 -726544 16621 -259567 -665415 -44709 170173 -3359 -393967 -649102 887055 -543742 -762105 -513430 -596304 168638 -742293 -257308 229471 -909868 -539714 -658254 -441675 -33765 -740595 -47623 -432000 -401411 -909167 417765 661648 319728 -996959 205144 597528 -578290 345018 -490648 381089 49244 -742606 -46311 -149701 -261615 479335 -165590 -9341 634807 456784 -19903 -624508 -941138 933749 150617 -34162 -677640 -7080 -761710 8420 124272 764980 22492 114287 120626 -952095 -395334 -734774 259497 767228 27686 -844584 -127849 -94149 422437 425010 419125 515408 41876 -899710…
Output: 1146628

Example 2:

Input: 2874 -728147 599769 -497540 -643271 476531 -953616 282915 123751 -857884 -927118 -234382 125112 -310553 -655898 380598 -938351 -603416 -954042 -18641 774468 905160 -865589 -118166 -651371 248678 -931503 -935920 -507480 -655879 -212262 -661018 -921533 -504351 -88772 999971 474569 -482001 -249537 76498 -964711 605924 849102 682437 421666 -606892 159726 336577 -231301 773935 -820360 -873575 100390 586384 960726 -275566 -651712 -54973 -565933 -719898 -997728 871269 437310 -63775 257084 -284900 -976563 104201 -336873 120560 -398894 -291714 -912328 -258135 -176320 -280977 335969 -945804 -815648 849618 -660809 413828 734962 32211 -282783 578903 40309 -956961 518801 -803194 -972328 757264 -541839 -332239 633681 -436563 516494 558181 42140 899164 412517 -577194 -345929 -719231 18443 -111682 -163044…
Output: 856332

Example 3:

Input: 3014 71203 -180571 198449 -857191 -626478 -821360 944065 -219142 85308 875419 -50009 953916 -161680 -450176 -118557 863010 -359919 563829 342916 -746738 -660213 36649 -455816 168611 -771524 -501999 528023 -434381 -846546 -926105 -867603 -154263 -841754 -53894 -304633 -895092 682244 284997 434359 -581637 163575 -772933 -288845 178778 582288 577022 917738 -444636 671298 260388 -734616 -104757 746143 -850298 -324626 933566 785539 463193 -360155 109404 -212572 535841 -645898 849842 463080 419318 165486 129623 420420 -74342 -764758 702038 686594 -835948 -672787 980034 827995 -906816 214847 730363 -655637 -698714 560575 -522722 -459546 335913 781425 -653924 -634448 277733 985683 -870523 -198922 562181 278936 -72144 -472200 300029 -587206 -448847 734954 346347 -667819 -888399 -550422 849428 68049…
Output: 2484576

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.