CT51537

Prismatic scrolls Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The reckoner Xavi has been asked to publish the quarterly findings. On the desk lies a long table of scrolls readings. 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 <= 1665; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 936 -617406 -840013 -970894 -437751 -643310 -826719 -91890 -655615 -976881 -845558 -852793 -926066 -705613 -44309 -509957 -626541 -886235 -16533 -155123 -474108 -962077 -624014 -914078 -18799 -626643 -596452 -373030 -655967 -285106 -616541 -3204 -794051 -337975 -496541 -346354 -72262 -977286 -318254 -527080 -73309 -317106 -180393 -844680 -754772 -797706 -546942 -734576 -682633 -235135 -982437 -678847 -370184 -688971 -987295 -280241 -594748 -905811 -641722 -907602 -441056 -44088 -864904 -550390 -740091 -66753 -805645 -590199 -765709 -328917 -210315 -570623 -25689 -511787 -140778 -433640 -865202 -292371 -511078 -157497 -750949 -759404 -928558 -555031 -753214 -667257 -504015 -947910 -133389 -129438 -264932 -408561 -554177 -255005 -762451 -963654 -536776 -409827 -213355 -356759 -287548 -900055…
Output: 360495

Example 2:

Input: 710 -505463 -520701 -849454 -674045 -303454 -851012 -658442 -783426 -642103 -565687 -17881 -464331 -275475 -688514 -34987 -435356 -202044 -823456 -110216 -535422 -876473 -112661 -924307 -479067 -987241 -920567 -489601 -436303 -482596 -149116 -234195 -227414 -264067 -785927 -811841 -91373 -645294 -473831 -424439 -538733 -612520 -98350 -747959 -176499 -98637 -146145 -748869 -208599 -679110 -422556 -447903 -935342 -703706 -165065 -631277 -557882 -175668 -314423 -887446 -580335 -513924 -459169 -215050 -747653 -22265 -298323 -111960 -398836 -709375 -812108 -834284 -994655 -741996 -760068 -656743 -596170 -700005 -986763 -187329 -492102 -329342 -526493 -607232 -802361 -646373 -947527 -478883 -880540 -135672 -964860 -819165 -667823 -608651 -919242 -13002 -531232 -388234 661 -18589 -723173 -798835 …
Output: 221599

Example 3:

Input: 52 -124772 -621392 -287030 -757737 -308039 -793680 -239989 -296217 -76270 -966946 -803098 -704136 -104107 -89105 -349037 -225905 -477303 -326724 -93468 -420804 -477294 -801622 -327829 -686494 -535591 -832102 -250058 -436992 -203474 -311785 -664322 -874491 -532375 -850469 -505489 -962391 -65915 -237609 -39731 -975099 -235163 -979021 -148918 -138703 -238345 -949164 -353924 -930403 -425342 -253823 -893591 -15320 -51060
Output: 1315

Constraints:

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

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