CT39896

The Frugal Pairs of the Pearl stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the heron rookery of Longlegs pays by the answer, and Yara 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 <= 3674; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 2543 -898386 -204344 -600264 -405274 -447714 -975274 -162958 -349857 -371434 -443346 -792508 -96844 -880197 -299042 -759539 -506200 -221573 -930740 -762177 -152875 -681467 -772517 -134107 -75209 -575717 -682661 -689086 -335818 -372954 -497516 -580669 -132363 -925402 -446792 -229879 -480088 -155330 -668204 -558398 -156068 -785094 -78417 -741400 -480832 -788741 -763031 -96137 -880910 -675316 -980990 -636241 -252086 -519270 -723604 -10317 -600056 -329497 -484190 -641818 -285522 -552103 -767758 -474067 -655643 -680460 -365163 -836319 -509907 -325232 -636157 -57003 -138241 -980258 -579668 -883697 -900099 -824460 -247487 -362877 -430350 -99986 -994349 -294934 -120585 -545913 -510819 -499128 -206575 -240396 -294971 -962654 -972462 -535905 -955566 -654544 -874501 -229879 -301726 -787663 -773828 -9…
Output: 1888900

Example 2:

Input: 2602 -281008 -764629 -469107 -415416 -853602 -385207 -727743 -979403 -441750 -361955 -79110 -829722 -373262 -360327 -3891 -516341 -159338 -127973 -76648 -392365 -272998 -174838 -272438 -407308 -114466 -262344 -859584 -807690 -54070 -494562 -99103 -694305 -227259 -145972 -753890 -363117 -502944 -612512 -930329 -745609 -194549 -186023 -225663 -804072 -912491 -181131 -420105 -676459 -229497 -467973 -548894 -595763 -737110 -781816 -927289 -231488 -932327 -817397 -670135 -215061 -811416 -257076 -671845 -894790 -773736 -45921 -298290 -340754 -882358 -404352 -794759 -532143 -434016 -924946 -343727 -217295 -184705 -939292 -952642 -566006 -349163 -389572 -864795 -480783 -569974 -47505 -952146 -849225 -268856 -849221 -93073 -269225 -953225 -835250 -366835 -978447 -208916 -506069 -616077 -567642 -258…
Output: 3236679

Example 3:

Input: 2374 -200590 -900483 -962032 -288833 -162744 -879557 -387867 -919480 -918198 -740833 -799257 -976504 -133509 -4017 -177663 -299118 -831943 -874006 -994297 -713822 -319349 -775043 -757707 -153096 -186413 -323524 -597076 -551873 -338272 -167090 -589360 -540251 -135035 -95363 -783009 -210901 -231749 -425533 -165662 -727864 -857433 -941292 -2886 -20401 -94135 -95916 -234581 -864591 -330180 -652912 -462506 -356879 -904562 -47940 -723238 -20467 -288652 -540883 -177507 -190628 -488480 -312445 -188759 -146852 -295104 -910558 -923456 -987850 -403848 -307811 -908168 -703169 -166369 -598566 -299657 -208311 -182417 -492141 -167419 -186270 -51433 -348946 -59201 -710491 -72474 -125711 -661480 -536529 -439170 -379865 -900834 -444891 -600040 -426500 -466482 -241956 -998830 -613103 -531284 -416434 -583459 …
Output: 2759188

Constraints:

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

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