CT47012

Nandini's Caramel scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the mountain city of Highreach, Nandini the measurer keeps careful count of the scrolls. win the guild's seasonal contest, 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 <= 2106; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1684 -180383 -266679 -963819 -861046 -62876 -389196 -226615 -828318 -195868 -710650 -373898 -936457 -973091 -98332 -139144 -701699 -147305 -32376 -995219 -274271 -530654 -49583 -775695 -936067 -835639 -321377 -844189 -129176 -356637 -26995 -138802 -751463 -833090 -675152 -928939 -356746 -679432 -787373 -490918 -69802 -444586 -313850 -765251 -522155 -402263 -392446 -439398 -68287 -429924 -289773 -907598 -855880 -955565 -187669 -985960 -625152 -835493 -254077 -780222 -976166 -109452 -984789 -564866 -483019 -463039 -208951 -942960 -451445 -347286 -931811 -444965 -242871 -365307 -72554 -908638 -243893 -178066 -902019 -15259 -572985 -178258 -497377 -479138 -9738 -186649 -299420 -719340 -110046 -901009 -646361 -58389 -327418 -430144 -278063 -978438 -304723 -819204 -811208 -738308 -980172 -766200…
Output: 1397964

Example 2:

Input: 1500 -79459 -203164 -527889 -108206 -43999 -835398 -814072 -688848 -877442 -143413 -130596 -620056 -481491 -221684 -879322 -329527 -27361 -240742 -702075 -994090 -498404 -847323 -715110 -292494 -466799 -190929 -464109 -321503 -783517 -422295 -106581 -38385 -193416 -414222 -109475 -757890 -146013 -274729 -502399 -618951 -19345 -54342 -70539 -612517 -523956 -597045 -875540 -219857 -940718 -531060 -142632 -294617 -648033 -948139 -94993 -684215 -400992 -809390 -256127 -305371 -754744 -636599 -865025 -22468 -242274 -63079 -801558 -994849 -568862 -954739 -257524 -437231 -357715 -798271 -234241 -450771 -547905 -437045 -688558 -868203 -563566 -499976 -416707 -15060 -68516 -953696 -140436 -110208 -892556 -108509 -584382 -106914 -697651 -63129 -36225 -538107 -107947 -342367 -657250 -493332 -564478 -…
Output: 1120233

Example 3:

Input: 531 -827843 -780748 -456445 -430462 -263645 -633759 -927136 -518726 -505137 -539857 -203474 -584828 -411540 -71228 -989441 -105635 -693726 -88946 -178621 -377015 -471221 -258535 -794298 -314803 -714260 -699192 -330369 -125005 -930855 -566898 -334512 -898575 -937875 -172784 -137221 -301592 -711145 -570191 -537108 -631341 -875629 -181196 -163306 -66162 -864378 -430084 -418511 -81638 -648039 -665435 -518316 -19133 -977842 -541198 -316018 -48310 -849220 -889441 -778361 -414061 -801332 -741634 -496374 -615879 -526912 -930166 -685948 -381069 -213331 -220206 -397635 -564514 -272086 -673775 -57725 -456346 -924317 -302649 -314831 -518086 -571121 -825667 -589830 -406841 -818689 -409585 -62408 -953490 -301286 -749582 -938782 -500529 -802635 -48549 -966762 -485088 -380756 -714347 -910178 -827850 -7367…
Output: 93259

Constraints:

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

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