CT40521

Vani and the Whispering scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Before the gates of the seal rocks of Barking Cove close for winter, Vani must finish the scrolls ledger - one figure at a time. 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 <= 1556; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 958 -352309 -533573 -290155 -659533 -13457 -23705 -772920 -650646 -562559 -705717 -745778 -237620 -801526 -18380 -214480 -119262 -119092 -94310 -180605 -602253 -735519 -862130 -152701 -764760 -852796 -5945 -99415 -127959 -277900 -835491 -923963 -87397 -183498 -497267 -147624 -776175 -917949 -206930 -287050 -684042 -643992 -173127 -896547 -533723 -189852 -16972 -247909 -554408 -165681 -776043 -734282 -840625 -118936 -733791 -210600 -593488 -112756 -538593 -686829 -967627 -331508 -220855 -129619 -106883 -315117 -940292 -948532 -620655 -519724 -363974 -462343 -394218 -804217 -652170 -2350 -92539 -638665 -822860 -891739 -98243 -456724 -581717 -983402 -126083 -17552 -291926 -892451 -580182 -210290 -40430 -820902 -950669 -872972 -949541 -994685 -6342 -846444 -359375 -150319 -754547 -33576 -75921…
Output: 422123

Example 2:

Input: 9 -715020 -448372 -635053 -812060 -840686 -859722 -975534 -853267 -977381 -616807
Output: 36

Example 3:

Input: 42 -730832 -943216 -40208 -220618 -928290 -889984 -942157 -679074 -308768 -421689 -249967 -885296 -105890 -889399 -204743 -576140 -493670 -379850 -748212 -219309 -615958 -561607 -446544 -800528 -643397 -287188 -822171 -200893 -931108 -382299 -233133 -255788 -710074 -202692 -449655 -18320 -91970 -672815 -870606 -382487 -945738 -113035 -86557
Output: 611

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Vani and the Whispering scrolls - MEDIUM Coding Problem | CodeTikki