CT48105

Baron's Ember Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Baron inherited the boathouse at the fjord village of Deepwater along with its curious bookkeeping system for segments. Time to make sense of it. 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 <= 2434; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1973 -740137 -847306 -898907 -883047 -388258 -778209 -114767 -564553 -338323 -320876 -955576 -232841 -824369 -839800 -162760 -163911 -904959 -340097 -217938 -215619 -150397 -612013 -446238 -505300 -274996 -290259 -716429 -948096 -727384 -192252 -52476 -712630 -359635 -136322 -174469 -566531 -769701 -271240 -483600 -936167 375 -345694 -139801 -624392 -79590 -537072 -942043 -416231 -129229 -908811 -42074 -54478 -90363 -178995 -15002 -937948 -730583 -965824 -8182 -685008 -52628 -50700 -435691 -871983 -467946 -767444 -111637 -216493 -33029 -623501 -692285 -157165 -424358 -188205 -218326 -852889 -263982 -394155 -403947 -764021 -791721 -804515 -662957 -705218 -67545 -433300 -36852 -534739 -771269 -691397 -910914 -405524 -882003 -620243 -218964 -423320 -100103 -85106 -835522 -814601 -414419 -8331…
Output: 1402920

Example 2:

Input: 1635 -371827 -391140 -913379 -949814 -15215 -945066 -889475 -99425 -598431 -82778 -154259 -633595 -81261 -944459 -467879 -854687 -564191 -174516 -124030 -633613 -215314 -618811 -380150 -976123 -149268 -602235 -906895 -208644 -964562 -99272 -914688 -423744 -57506 -211262 -55566 -571790 -508934 -246227 -768952 -852308 -864627 -511164 -431608 -841031 -395313 -498931 -466290 -441925 -88554 -12096 -335572 -709031 -857195 -237045 -48063 -652741 -670490 -317433 -326189 -100502 -926596 -822751 -786775 -216260 -292914 -475918 -442688 -133480 -670649 -923691 -52283 -201710 -309981 -2558 -706387 -366265 -487890 -20225 -352810 -572931 -500812 -521150 -176151 -122366 -876240 -114241 -506791 -932031 -179359 -954484 -750695 -72011 -625341 -619811 -409521 -799048 -455116 -628140 -404723 -542049 -623400 -2…
Output: 1254511

Example 3:

Input: 325 -869666 -665449 -935155 -311421 -908816 -833911 -18402 -817885 -322806 -69285 -204137 -108614 -74189 -497605 -426117 -3971 -709874 -162804 -783357 -252099 -655197 -448401 -659994 -908821 -961359 -2700 -631556 -849095 -139109 -570647 -957180 -755080 -563901 -27913 -678284 -568443 -373285 -546458 -806947 -87711 -541297 -836294 -485381 -679729 -978794 -92470 -231668 -336429 -563138 -589952 -217035 -180515 -381176 -774437 -728043 -446376 -870006 -910982 -876111 -820940 -51671 -383784 -954610 -977727 -907288 -761352 -401859 -22000 -685179 -667809 -347819 -786122 -84489 -554517 -634048 -419829 -181042 -229169 -870122 -504724 -258501 -549547 -166245 -988198 -158181 -486436 -797414 -152748 -673491 -439411 -652124 -318703 -957723 -681830 -41298 -745092 -317747 -83991 -196971 -644381 -602146 -73…
Output: 33746

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Baron's Ember Ledger - MEDIUM Coding Problem | CodeTikki