CT53810

The Golden ribbons of June

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the ink district of Scriptoria pays by the answer, and June intends to earn it. First: the full register of ribbons. 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 <= 1853; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1343 -66659 -388897 -265172 -816226 -472449 -293013 -426879 -47249 -477881 -739833 -405525 -818252 -568417 -621043 -347855 -146255 -428644 -971368 -839734 -629549 -654782 -480665 -819691 -464161 -354887 -567699 -513379 -377758 -271948 -73532 -597393 -153607 -692712 -405412 -611879 -987652 -396829 -855499 -604244 -957003 -580894 -676372 -518281 -906975 -365228 -563873 -237233 -561692 -528520 -637696 -592864 -905930 -391384 -36200 -261330 -929123 -327652 -29510 -206217 -138228 -314569 -522396 -34338 -695832 -524232 -803884 -728734 -480309 -18479 -147650 -28859 -977683 -451498 -485125 -162421 -544666 -704978 -431795 -604877 -42452 -589197 -823516 -583942 -591390 -130009 -361362 -9374 -564189 -434830 -502507 -243816 -737288 -407351 -243103 -844632 -695022 -779970 -416068 -370605 -833086 -10780…
Output: 899016

Example 2:

Input: 1206 -601873 -711021 -668082 -257813 -942093 -134058 -834819 -486940 -514344 -223097 -251329 -72437 -571318 -642986 -955950 -307220 -314460 -800751 -92698 -46167 -544955 -795689 -845668 -730780 -405434 -191509 -170504 -584305 -153770 -737044 -991618 -209582 -531651 -945023 -359589 -668400 -180011 -724593 -581438 -494717 -568527 -79276 -805445 -728469 -95611 -222586 -689947 -560692 -170131 -176809 -259095 -19748 -230876 -79843 -407358 -981995 -450289 -720133 -501621 -817701 -455738 -77309 -913031 -296632 -410250 -865393 -480185 -815713 -955629 -520118 -928986 -890785 -394338 -116946 -862814 -530077 -748261 -520876 -5204 -959964 -688528 -977441 -363928 -31705 -600647 -984325 -521144 -704717 -597476 -669077 -601171 -673954 -521000 -893481 -218396 -837779 -699757 -806457 -432711 -955451 -39748…
Output: 609960

Example 3:

Input: 1198 -261961 -624387 -878469 -863019 -400121 -527541 -815560 -359831 -468427 -875445 -569478 -325340 -824965 -864921 -887660 -927741 -11856 -402618 -821141 -651773 -993707 -283361 -903704 -202011 -53142 -315730 -781425 -481654 -366312 -699615 -404578 -673082 -792972 -764174 -74347 -433575 -499923 -912515 -333883 -597511 -37248 -102244 -410695 -534628 -130 -591449 -568557 -273593 -183817 -15308 -983683 -918156 -738678 -85101 -559336 -748165 -618292 -363141 -630475 -661331 -799402 -698285 -639592 -990814 -147296 -94225 -534352 -846889 -139268 -490731 -346659 -631908 -879481 -403923 -310383 -560103 -215233 -502072 -144084 -793933 -226024 -819197 -684886 -396431 -706023 -722565 -691852 -468537 -808324 -36534 -577514 -880883 -482916 -881718 -896173 -710116 -668782 -909275 -186516 -212351 -87267…
Output: 690760

Constraints:

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

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