CT34650

Chaplain Counts the panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the pine barrens of Needlepoint close for winter, Chaplain must finish the panels 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 <= 2373; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 2327 -859827 -9820 -571014 -280438 -939408 -686442 -6950 -19725 -927796 -70537 -718682 -671588 -502966 -689274 -40327 -650361 -84192 -919662 -866730 -235408 -406947 -937456 -868683 -201145 -218086 -755296 -618007 -755764 -163757 -829295 -373190 -904879 -688046 -135207 -258694 -308915 -131488 -664021 -814209 -186251 -9099 -326628 -644723 -205816 -680465 -686107 -320029 -588200 -355234 -378412 -424913 -241508 -861402 -697327 -816156 -238872 -300496 -354149 -855597 -102112 -442072 -922595 -876786 -369468 -625985 -364380 -789324 -980328 -916184 -26350 -367890 -814892 -628697 -606954 -938242 -491535 -30588 -778186 -948543 -342590 -808927 -155696 -161488 -502629 -847498 -404968 -459885 -647725 -175960 -649460 -86996 -726851 -422402 -750528 -264876 -47132 -216611 -646820 -98699 -420754 -789791 -3…
Output: 1698043

Example 2:

Input: 493 -528797 -156500 -275823 -418088 -786283 -555562 -899426 -556069 -28345 -146144 -86338 -126099 -556326 -90231 -520263 -323053 -766228 -474833 -146847 -660282 -31356 -549421 -236329 -172923 -367704 -823756 -264659 -362390 -352801 -467254 -692449 -478252 -857197 -290952 -598193 -435154 -65046 -821445 -538272 -59859 -191856 -424867 -104032 -49947 -213361 -804654 -376024 -283908 -72515 -863465 -987987 -669216 -789896 -158385 -131408 -92169 -10511 -820161 -67082 -343386 -92477 -968236 -705648 -954315 -629905 -163519 -193298 -262972 -934393 -219024 -791611 -910470 -579829 -816882 -102798 -686825 -115657 -976220 -268026 -145656 -961775 -34798 -473568 -970599 -475949 -628870 -302542 -972108 -710460 -770585 -199617 -77153 -590937 -727183 -804295 -233251 -309486 -594832 -555824 -621874 -749462 -6…
Output: 102943

Example 3:

Input: 410 -509063 -731829 -94305 -624256 -857661 -666851 -875665 -363249 -570259 -698657 -901116 -753525 -64720 -727915 -466802 -426733 -653480 -463366 -49232 -847145 -222181 -589650 -615146 -415034 -661307 -774798 -687288 -34368 -643459 -101539 -602593 -519480 -375026 -518333 -208249 -47387 -205426 -382294 -607235 -338573 -773130 -504506 -160249 -939053 -407082 -311212 -656605 -423109 -554698 -604952 -514418 -116059 -636371 -196665 -529013 -489123 -487087 -524498 -339364 -424423 -3775 -516618 -154002 -101404 -873215 -710173 -592493 -786874 -587362 -905550 -629255 -470172 -80814 -523252 -345666 -477663 -179445 -529283 -952259 -864091 -920248 -303431 -16529 -854220 -857603 -637325 -204263 -804177 -680895 -752724 -776601 -230033 -711163 -280565 -399610 -868382 -793443 -61928 -141375 -395605 -97754…
Output: 72454

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chaplain Counts the panels - MEDIUM Coding Problem | CodeTikki