CT37717

Last scrolls of Gail

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the river town of Willowford with crates of scrolls, and Gail the store warden must account for every last one. 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 <= 2388; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 176 -846970 -958613 -594903 -475404 -4001 -394533 -834663 -255302 -540281 -888651 -14689 -522721 -633087 -813043 -726712 -31988 -855038 -189787 -148458 -88111 -545883 -566027 -139492 -797643 -300551 -234070 -787357 -200573 -919596 -936417 -995475 -768753 -397680 -906474 -810037 -410979 -452885 -366829 -810335 -53419 -434151 -762687 -777717 -548463 -788485 -644110 -274467 -58582 -220681 -430480 -217339 -547833 -800076 -950351 -716275 -108495 -814314 -763087 -204640 -386147 -691760 -232508 -179135 -894941 -686339 -10274 -691678 -241972 -557305 -158618 -631565 -221426 -955183 -467091 -895320 -993583 -727226 -898378 -482771 -719327 -389212 -914977 -458227 -118417 -673963 -117007 -411629 -948693 -579954 -963191 -748109 -900108 -514771 -61759 -77885 -865173 -977446 -359349 -532512 -263101 -32944…
Output: 10813

Example 2:

Input: 1181 -340238 -783907 -232784 -5829 -758767 -108299 -749862 -990051 -271648 -964668 -481954 -127001 -815407 -200987 -893063 -945202 -747309 -754954 -413378 -159299 -855861 -764711 -816405 -559677 -355781 -552576 -552015 -836409 -950729 -694349 -604447 -255311 -54252 -276483 -118403 -867295 -876014 -93739 -869570 -442542 -233909 -154254 -964923 -438465 -307656 -946579 -837189 -917056 -988807 -740935 -414701 -311206 -809933 -233161 -957804 -762803 -980821 -673585 -473665 -239489 -168516 -362074 -935812 -474234 -105448 -317478 -886908 -875387 -221270 -862237 -759173 -657997 -229568 -949023 -985192 -786386 -562471 -282262 -130586 -456138 -890068 -432862 -816124 -810088 -616389 -736241 -841991 -329038 -256745 -105528 -279627 -55806 -340007 -977561 -397112 -19965 -90095 -471421 -191591 -867916 -7…
Output: 656444

Example 3:

Input: 700 -667239 -966239 -42201 -488281 -887189 -746332 -493540 -973973 -760138 -326403 -683390 -53699 -940963 -217530 -437341 -24461 -362578 -938989 -27578 -341229 -344934 -400565 -61244 -478153 -948574 -752206 -28353 -795819 -938833 -199500 -814898 -178809 -929682 -47275 -532530 -986786 -235834 -493824 -94859 -66709 -490389 -691581 -315483 -258875 -840159 -590837 -117672 -172445 -766699 -182523 -998 -134907 -913114 -16175 -329822 -634429 -618272 -11848 -171838 -1237 -888798 -918966 -848587 -861130 -691185 -565302 -808421 -735869 -23686 -300314 -87480 -86816 -827809 -293819 -934467 -630274 -83902 -770244 -932598 -952506 -701999 -245917 -364662 -577346 -614500 -433014 -706218 -531246 -65576 -384343 -337901 -639732 -359413 -988044 -624549 -948142 -848132 -665100 -884621 -402081 -742642 -148661 -…
Output: 196630

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last scrolls of Gail - MEDIUM Coding Problem | CodeTikki