CT45744

The Frugal Pairs at Argentium

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the marble forum of Argentium close for winter, Quinn must finish the ribbons ledger - one figure at a time. 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 <= 2937; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1407 -25305 -673386 -989672 -927770 -373976 -339854 -255011 -280323 -957106 -952961 -973963 -196049 -434976 -181161 -146679 -479026 -436075 -24738 -205392 -207793 -859512 -875029 -773924 -50853 -907622 -171886 -294916 -870056 -313136 -145614 -694220 -208427 -47475 -682218 -744910 -271194 -617603 -517713 -120240 -100476 -756560 -954420 -183063 -525327 -860305 -838321 -123266 -253953 -606865 -67963 -965445 -143437 -416698 -460503 -376341 -702447 -973217 -213637 -607601 -214881 -877486 -947103 -621644 -10281 -705688 -151676 -546025 -877611 -507845 -859667 -574896 -42110 -389600 -796348 853 -307350 -732426 -835536 -913477 -320903 -982237 -460483 -532700 -659014 -440870 -75761 -496217 -361279 -725991 -643380 -790012 -703066 -700568 -598399 -336360 -837080 -52478 -435124 -558813 -553843 -463720 …
Output: 988807

Example 2:

Input: 2399 -860310 -355150 -212166 -727246 -478145 -755537 -483474 -783826 -507977 -857104 -790109 -675838 -53615 -437111 -722862 -336117 -272174 -977959 -918412 -751798 -839688 -303146 -511634 -491012 -847419 -999727 -228733 -883 -98966 -337781 -891884 -640975 -750487 -761757 -930594 -5338 -941036 -586167 -836002 -771270 67 -118943 -491538 -675747 -173787 -27294 -620144 -740686 -763464 -861445 -43873 -166500 -759791 -339162 -166111 -382081 -521235 -937649 -500017 -440920 -277260 -547078 -356624 -573378 -707775 -240766 -899699 -493159 -510935 -325453 -477497 -85614 -746715 -805809 -657461 -354416 -106586 -516890 -801434 -206548 -413184 -856446 -680933 -488247 -346512 -599480 -846572 -967801 -323459 -98721 -271738 -338366 -784836 -684755 -318483 -683567 -59982 -975097 -520861 -904864 -684298 -787…
Output: 1824434

Example 3:

Input: 1042 -694442 -163869 -32183 -77063 -750568 -46083 -330325 -977176 -978400 -867306 -680829 -292084 -855506 -798594 -389129 -170991 -400944 -679975 -783482 -604629 -636321 -89953 -684459 -949585 -838 -855204 -184017 -944952 -526300 -259635 -464349 -876411 -534182 -516791 -558595 -885872 -86140 -649969 -559496 -286737 -626121 -63191 -114746 -309794 -683835 -77716 -969314 -232559 -548230 -680082 -627842 -586632 -226742 -985955 -282626 -461623 -992938 -535050 -49048 -761819 -779037 -260623 -605910 -10355 -749371 -493679 -607174 -536309 -201878 -413515 -329387 -229868 -963131 -785473 -728259 -129956 -885904 -889116 -69637 -10967 -211778 -418465 -641056 -387943 -266433 -54219 -811678 -767535 -605548 -632163 -551632 -674766 -643402 -266728 -132472 -465358 -35039 -167554 -535862 -622148 -210120 -89…
Output: 412909

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Frugal Pairs at Argentium - MEDIUM Coding Problem | CodeTikki