CT44421

The Frugal Pairs at Cascade Vale

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Sahil found an old ledger of stretches in the dairy attic at the ribbon falls of Cascade Vale. The margin notes pose a precise question. 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 <= 3250; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 2518 655867668 753585802 737246927 532620522 573878421 914930811 357417668 306569639 354756026 390097697 151415719 788044675 321006782 812905136 126641529 145829043 242779659 549726091 248970862 251444543 436800424 61377083 427234003 884636253 95971464 942335333 705425322 924379281 702957784 447612890 139094195 971355140 664786670 786238345 72888162 246966740 239111550 833717970 742007549 408449633 186435773 453803569 997127135 843001231 568464463 557920552 51968039 850119516 491092917 324194417 640835367 731092737 361124806 61862531 302854259 384778518 194805068 204746886 460190272 55364094 178836652 69370211 355752275 390106504 866967641 857100009 166854251 12968569 822475772 657024381 640932588 405407601 417939374 716591561 128680641 725772256 890989081 129942469 80392921 572332035 8768…
Output: 680406

Example 2:

Input: 121 34308785 273051736 862624549 397952419 449162540 466840134 412664515 574459487 465937129 921577114 766578286 479027149 942039871 347193306 248023100 511457884 431160858 763231516 58513966 8060568 863703517 800586190 248090961 29022281 342421496 530041733 600290211 9734036 310849944 789678250 764743052 96536845 15415071 860024592 470270849 40446166 791542399 241502233 44910105 573094121 796352095 443908457 669182802 876729195 148915963 938507090 82117703 502607997 18071330 684439899 497392783 330862614 268167118 498617812 75977227 834318000 172682479 584087482 308213217 914482057 632326555 374678982 54496776 670410456 491381322 653190842 431104076 644733168 736712589 336318970 78294358 242365274 372336005 678951170 415459170 324679011 942416613 406213919 870315015 574787589 593207270 80…
Output: 10

Example 3:

Input: 2709 1025791465 392231802 163068989 73500511 707113105 149860520 529880780 461398513 520802465 51793852 584101626 775415882 308361661 15925985 428824621 669940727 857280444 790943853 427781789 441167560 822886022 726241696 13269832 609627401 213562398 321069519 2680031 782325532 780202745 958692909 410083406 109682728 640353420 204944860 826480143 183589446 606900705 139367585 474179323 748877366 407410097 147021221 715609960 372721074 749841319 32230181 917833839 21040003 177866736 676555894 928135965 708476736 606960429 704079431 667222612 269756739 830609010 111361684 315064171 624085642 427086919 770625547 277924368 389074243 418645069 431932843 950983813 647061016 673118535 663172138 751204886 74249585 437938815 321999468 673659019 600444820 676960742 623686015 276710341 641902160 587…
Output: 1909020

Constraints:

2 <= n <= 3250; 0 <= a[i],k <= 1000000000.

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