CT30473

The Ashen Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the zephyr cliffs of Galeholm, Ravi studies rows of segments entries. One clean number will settle the guild's oldest argument. 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 <= 3658; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 1933 -611705 -670290 -932275 -5729 -227031 -744732 -480025 -730000 -411481 -161086 -857746 -830876 -562676 -847988 -725021 -951870 -669944 -853090 -867339 -37965 -638109 -221869 -187461 -415196 -95855 -840315 -517140 -36348 -80476 -784830 -326471 -983359 -155093 -696312 -313356 -900936 -516767 -218829 -662904 -516725 -15437 -480958 -661098 -463472 -314641 -82556 -304444 -392049 -455431 -285773 -108063 -661365 -202750 -675262 -603470 -730749 -275978 -638983 -241791 -623443 -545385 -175500 -415616 -108446 -286985 -858433 -364034 -839363 -251713 -73690 -813555 -659343 -99550 -138979 -699664 -202920 -363384 -98977 -558628 -253547 -270557 -764704 -904546 -566037 -833562 -999907 -166928 -342158 -426376 -950322 -56252 -894230 -165421 -406173 -993314 -850405 -534882 -597246 -935191 -651492 -571482…
Output: 1504731

Example 2:

Input: 1727 -700277 -183655 -840942 -480441 -761000 -743202 -242011 -550780 -97721 -297555 -751468 -459987 -283126 -238413 -542289 -58055 -520634 -264733 -879059 -186873 -747445 -422458 -614701 -805805 -691965 -593857 -930888 -606127 -250034 -662965 -277791 -7770 -793761 -830998 -726071 -362058 -106568 -291291 -461321 -524740 -670946 -335274 -305933 -1380 -666442 -146576 -766176 -941049 -340307 -115140 -631271 -581942 -403985 -997283 -450531 -530344 -893948 -906593 -718868 -39401 -947809 -598707 -445492 -709042 -194090 -896428 -467821 -591334 -744521 -43360 -654967 -611700 -457349 -549576 -916100 -898061 -950220 -983729 -406477 -644960 -795111 -575492 -413307 -476767 -639600 -141311 -308585 -146022 -142637 -192542 -234971 -273670 -529230 -34686 -355163 -346194 -316888 -413033 -320661 -460013 -368…
Output: 1121139

Example 3:

Input: 2050 -437771 -800150 -913230 -134396 -294177 -755725 -869808 -913499 -226227 -77309 -874740 -382602 -597101 -861116 -984195 -366625 -971807 -764742 -426616 -415623 -431108 -649591 -674494 -526446 -609055 -562429 -345864 -475782 -768318 -49102 -105097 -880241 -911694 -872399 -158441 -506424 -472056 -379914 -333518 -555249 -407234 -1326 -648746 -862988 -502 -835453 -716914 -463317 -200327 -538146 -65917 -963329 -162112 -619698 -760208 -90472 -542143 -457810 -892775 -825857 -369048 -763105 -418442 -299865 -572337 -627914 -785171 -91301 -29250 -942972 -893026 -725716 -638517 -403040 -796247 -941086 -272196 -263728 -172979 -905796 -242845 -478847 -865577 -496366 -642057 -404100 -120016 -636874 -307461 -404969 -842615 -565318 -867224 -12188 -778873 -214096 -255935 -837436 -275907 -64606 -416087 …
Output: 1912086

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Ashen Frugal Pairs - MEDIUM Coding Problem | CodeTikki