CT50061

The Frugal Pairs at Saffronia

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the spice bazaar of Saffronia. Kabir spreads the panels records across the table and picks up a sharp pencil. 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 <= 3852; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 1195 1637616476 766999164 669466127 987056277 768405565 633460122 79558040 379602361 998206691 957937917 476239900 468011078 803209631 195200367 292638381 353137427 30753039 13675143 59651693 705644784 977616437 102258768 34730584 844976948 637491021 764349318 616691206 77620316 781280947 371090681 468529337 535670693 967863204 893650757 576588454 614127651 870953291 246215267 285391427 857187997 94942588 494344204 86121468 100199585 273814636 131725586 252216107 481538102 954746864 95218991 583074936 774008176 452227946 928167391 77210520 769471224 839989396 783116794 232872435 783631708 446502120 333764539 20955026 607697543 191029828 937670441 335369985 162288316 898155766 383797883 608158659 735123597 872369376 965491231 583875378 352849965 286287604 349336061 269276545 834135811 39148…
Output: 662424

Example 2:

Input: 3669 62333455 673589495 239424777 646612430 255915455 924961567 264879278 597909448 433713090 477947263 937197438 927156963 173136097 57079587 529798180 433185453 395997137 290405019 909485613 20944742 876376899 262950881 487555244 617386614 140820373 113776243 334393570 952855664 486136658 753010414 705729459 154182932 274551116 804925165 815111501 998367928 528992005 142536767 541038773 634808741 518791260 771630947 350617347 769881805 488505689 234501605 594472259 13738679 604050286 168370230 134940115 191904680 336597890 311954467 782212153 216036596 493704928 575182377 738144448 145929158 77900072 974489256 825620256 839661655 963833773 769783695 223876040 910704036 793149181 858049397 823050075 208093679 372457782 526676571 447768887 312371186 196307416 538466023 30654478 394197104 1…
Output: 12416

Example 3:

Input: 1407 1178565374 431094929 342642904 287291488 604164418 238076056 534889643 437118634 725800648 407705749 25465082 142477472 444793389 766275528 837736925 565382937 371517630 386658938 315021799 492927301 584587100 374329616 600142044 182624259 797960902 682263059 961867778 626419260 260304751 375430360 661095554 855080580 560891114 564149904 910366240 616026492 100260087 50955117 418810140 875648047 377913410 973411028 213396047 885880809 208591770 864277745 511851176 271757202 348587146 110843596 360117195 828772334 987304770 547865490 388202319 143139353 889457294 648603943 538299139 141186163 586964195 873130948 970768196 623149674 7088512 247288460 834141695 70056577 421544088 22509952 183237988 247474357 134353020 353558057 423544222 422219658 313211228 507552811 696745973 3066544 79…
Output: 652680

Constraints:

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

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