CT37500

The Frugal Pairs at Tidewater

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The council of the coastal hub of Tidewater pays by the answer, and Iker intends to earn it. First: the full register of windows. 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 <= 2812; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 2208 535291 739386 52269 853305 -798120 710060 -897952 -171039 7987 -957836 -928623 699164 373816 766690 684342 198033 -836586 258313 720169 -512143 912785 -67584 -540617 275638 -661567 17210 -233570 -227420 -672258 580362 180188 -764982 365647 163145 -325661 707944 56442 -421893 -149959 -796818 -37799 -780358 -972088 -977700 568615 89722 251742 552445 -34131 584405 -170569 -670081 -77442 -604477 -848664 -805211 -358492 9221 513654 -902197 -408513 399990 815203 -787851 -79875 248206 387352 167115 -913730 -684735 21500 -949159 -607129 388726 595652 -323477 -705081 -556590 55846 -256684 454062 709266 133205 609393 374936 -640083 511877 -96468 -157267 -69494 -484426 270133 649691 -492374 -355045 -64013 -316788 -133995 -651269 129375 -959257 -298142 740924 -760260 612867 204911 484698 882604 -…
Output: 1754038

Example 2:

Input: 781 -740666 898595 -846813 -429358 483546 72599 -221577 -989749 727353 209391 256703 891469 -340267 -952040 -263896 160969 -605007 -110060 968702 164817 863487 -985391 502093 -419625 890988 -23507 -994587 483330 310091 -490001 -207377 -740773 -346966 -432120 854269 -145721 -529913 461846 246620 727798 142511 586134 -361242 -219982 -397001 -394633 715286 -818154 -457404 -79260 -463657 366664 105679 -904692 568819 16766 -641711 -112152 523774 354979 -510979 726335 -24075 -708134 -997236 179700 -717633 200742 -506076 -265725 -531142 -664561 28073 214161 -872944 -341495 923286 31067 731532 -917708 836132 68273 695000 705245 -243140 277106 694543 914578 -630185 -877810 493861 145392 -721450 763202 432485 847874 114307 127284 32052 292347 439752 -327971 572010 377648 233121 783907 -562772 917516…
Output: 57451

Example 3:

Input: 2112 -432033 786869 -314578 430007 -797058 398418 839628 -800105 -172374 -603151 163512 -717511 767087 756614 906230 90080 -129029 902786 -747395 921013 -494747 432284 -131350 949499 713480 125445 -297623 -361856 -695612 -538047 -399507 153894 690809 -516720 -107954 -310126 -66469 -890454 -438362 938553 -3350 859555 758966 -636595 -279337 139526 -469734 -858170 16656 459177 -744282 -571837 755832 855412 -199996 -464387 -243801 977269 543708 212569 442147 -739636 -92388 -229625 895816 -682990 -238467 -501425 -448249 -912994 -812883 -113910 -816591 -258421 806422 -171028 461794 351819 -45911 418968 -442569 947965 751787 -109079 613843 -474710 -569466 592343 789963 -370724 521347 -866716 297933 -940968 112179 869256 688118 474069 -780564 -388130 429105 -682837 886009 543354 -902567 358892 972…
Output: 706205

Constraints:

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

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