CT40627

The Dusky ribbons of Gail

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the willow walks of Reedmarsh with crates of ribbons, and Gail the tallyman 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 <= 1695; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1302 -588280 -737500 -456522 -676174 -17553 -852278 -348477 -238889 -116019 -903399 -936573 -125035 -315565 -268768 -441009 -723854 -208592 -815358 -828233 -456017 -620995 -850101 -26476 -7924 -564001 -305173 -182264 -20634 -422403 -277785 -875099 -387757 -38282 -755962 -64544 -7372 -644917 -602725 -997614 -502231 -623676 -416559 -986517 -551831 -4868 -357405 -114804 -37407 -801260 -974978 -856327 -190589 -239542 -152282 -607297 -788103 -900638 -897174 -731364 -244731 -453894 -550699 -758187 -142086 -719057 -903307 -373941 -289397 -3853 -952817 -998963 -573747 -690166 -458647 -745291 -268135 -251218 -432423 -62646 -676400 -217157 -752479 -185493 -822240 -221510 -293044 -961151 -436394 -592588 -287594 -253646 -236695 -780190 -344331 -445495 -970423 -701490 -572208 -133023 -829387 -862694 -5…
Output: 703187

Example 2:

Input: 173 -935104 -621923 -404641 -627924 -124971 -788042 -784322 -267816 -685622 -404785 -74596 -310567 -294355 -333545 -771573 -748893 -561605 -269286 -424752 -993894 -176525 -930678 -989162 -263428 -813747 -630911 -321904 -894395 -504794 -630199 -587422 -76010 -63028 -700974 -545884 -302368 -442594 -824382 -48408 -828183 -63054 -472528 -207161 -18372 -689779 -269094 -958487 -917525 -514645 -720722 -182410 -601924 -563695 -246631 -255631 -451446 -836314 -639436 -680836 -899744 -450771 -263337 -218438 -786545 -983741 -444332 -127532 -771869 -662969 -823243 -748107 -502078 -379994 -155971 -627285 -77508 -803962 -564969 -340637 -273235 -663049 -375526 -14079 -978292 -348905 -290899 -107054 -814127 -393628 -106128 -651662 -909508 -254013 -202129 -542409 -137005 -105556 -249119 -598659 -332642 -628…
Output: 7730

Example 3:

Input: 675 -69409 -147128 -631623 -530864 -139749 -34913 -731303 -289806 -294871 -48506 -383499 -539837 -431631 -588787 -210228 -695182 -277295 -600180 -967851 -918377 -245031 -348648 -993145 -595070 -944771 -134651 -156393 -105820 -663240 -850379 -673603 -272129 -546682 -272178 -665833 -787408 -452190 -641364 -566783 -302864 -908013 -960433 -531425 -735621 -783093 -667280 -848519 -518348 -434036 -277123 -28206 -97550 -363846 -124737 -923529 -101677 -457670 -201617 -786744 -17320 -534910 -337191 -253447 -770671 -446535 -423336 -906964 -699883 -982688 -234019 -676998 -133293 -314052 -371224 -209217 -847081 -16816 -608617 -572320 -758800 -671881 -775836 -721132 -616312 -814211 -200735 -3590 -373046 -351866 -526552 -607281 -345231 -13862 -9541 -407818 -384007 -914706 -615405 -565387 -743740 -653372 …
Output: 226937

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Dusky ribbons of Gail - MEDIUM Coding Problem | CodeTikki