CT31097

Devi's scrolls Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the gull cliffs of Screech Point, Devi records each scrolls in a worn leather ledger. The guild wants answers, not guesses. 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 <= 2005; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 373 -431501 -404391 -309320 -564772 -347379 -793267 -904108 -811264 -989237 -97763 -422248 -919639 -695980 -802896 -242228 -231601 -923095 -819994 -170835 -87358 -814490 -663854 -527968 -657246 -199907 -827182 -141661 -886694 -904089 -866477 -223447 -609790 -985991 -192877 -172014 -636800 -357125 -162681 -813878 -537388 -432727 -741177 -595345 -5526 -163029 -628013 -395504 -616896 -750899 -841177 -165875 -418787 -996945 -373657 -301760 -671645 -369914 -219137 -587506 -546101 -465697 -271149 -512151 -619815 -92760 -491867 -457133 -522067 -887730 -408261 -721933 -210643 -546249 -700380 -576009 -606027 -831535 -376944 -490360 -709178 -440779 -658806 -315094 -646484 -194471 -555446 -486222 -884798 -49834 -138305 -635977 -264783 -56752 -318655 -993101 -864483 -294488 -73515 -480856 -203803 -196…
Output: 64130

Example 2:

Input: 971 -329661 -528256 -87105 -744990 -695958 -216133 -839478 -760518 -798402 -465530 -686519 -722562 -521738 -21321 -811457 -928947 -11451 -620745 -856141 -936459 -537339 -300550 -565429 -222944 -707126 -229409 -569535 -232511 -284766 -940076 -882380 -333789 -586627 -853994 -750151 -901221 -283186 -653239 -721207 -619415 -866569 -926773 -755308 -225987 -49256 -710450 -247417 -918647 -720975 -691503 -95651 -230144 -542262 -481720 -15804 -263886 -902492 -243685 -326869 -964251 -153841 -537911 -549958 -248034 -327881 -764166 -304701 -100838 -865325 -749805 -415053 -582064 -752942 -757976 -783902 -375417 -211771 -629237 -490974 -714642 -883925 -919125 -725664 -115939 -974019 -228693 -434367 -224302 -191798 -940585 -46316 -754254 -708365 -24850 -901410 -551650 -334372 -102446 -848674 -615721 -301…
Output: 448096

Example 3:

Input: 899 -462387 -453751 -235301 -506565 -339929 -623179 -976108 -969997 -463795 -511447 -356484 -587849 -167175 -533665 -510640 -120792 -630518 -960149 -745544 -866471 -604017 -272788 -555591 -675074 -767494 -623330 -738792 -909176 -69848 -360843 -789009 -199527 -454866 -816701 -584699 -211841 -546759 -806590 -945275 -898146 -855559 -685746 -171822 -747465 -464481 -640925 -710788 -386307 -868514 -189349 -373942 -434921 -80249 -300170 -669605 -490112 -375892 -993813 -357219 -203500 -156856 -200754 -592183 -849674 -857906 -670968 -672558 -511479 -373402 -708086 -22381 -520181 -416462 -22255 -448203 -960524 -291694 -794456 -986411 -303072 -577698 -527166 -516723 -36867 -19696 -8100 -151296 -873070 -392087 -4588 -709430 -479161 -640825 -101889 -490189 -734550 -524953 -468759 -267290 -898355 -80470…
Output: 356161

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.