CT30292

The Gilded panels of Quin

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Quin found an old ledger of panels in the exchange attic at the smokehouses of Brineport. 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 <= 1622; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 758 1517808089 132249672 163978380 497798657 515230936 925221171 328802390 2045600 846001469 771223835 4018554 558554169 449448112 295261897 670590886 544785418 207255076 167228124 680231274 484580648 52333698 476348137 905471956 277325484 721311798 464049592 676865022 999307721 829004630 578376192 810700423 673857461 375196786 950134010 939673471 516402632 694925700 582538377 742048907 955167822 896570747 193844187 846131667 885865752 755421864 877449153 709614483 789992375 687943909 283903160 61459017 981079124 225201164 69214151 9859472 920916277 582857130 228422155 734174990 858870296 37873689 311197317 467148546 728099160 103094909 95954471 723456142 992143537 174480964 79495061 631282479 642265817 777013113 131493121 857239882 930064213 858033088 682317689 762089551 942285296 9159225…
Output: 254109

Example 2:

Input: 701 195613084 590183274 300681606 693175891 554630519 283474139 200110209 523493160 371606116 65801685 525260352 594672167 217538032 409615150 784447615 325125279 255715559 792551697 665888766 769156314 29108436 610607823 963792673 511494461 689279151 841582782 335597714 487959687 637314820 385105887 555151345 699023518 133625028 495836872 766402446 371482756 830051032 552177136 488220660 757213753 862913786 404940515 427880243 970565894 639972190 242990574 590735201 290761426 489396417 766717193 190651819 886022940 954358103 451468612 773967933 850944390 124998511 872545599 458190948 659013910 759974062 903151080 901976161 625704785 416852062 638523435 602827266 426407485 4256507 267918921 680277847 794800493 139265509 791716882 511850561 295559979 149472471 451841072 807855474 943064536 …
Output: 5063

Example 3:

Input: 1013 616965913 165943926 811107596 206858367 699715020 75244531 346047123 697786203 357886320 34034230 347588640 730237401 978660562 992719594 243459537 863814436 300164859 685780735 905198752 253643485 762269095 649634247 988469281 28325350 669132612 660092915 14740352 981049738 850907773 835858174 149595808 4267794 405107709 543266653 554981674 142479825 850261471 657294389 26738170 356482115 907485258 965685695 103055292 352581775 433144527 547587950 220780864 90487327 157117763 359007148 482025356 56992707 538017771 419218871 87664244 850612675 493829662 347812262 469704782 876735615 961239065 350092440 996534091 161001624 927764151 317248790 828538615 235598876 168741463 37145278 361874184 659908878 967202416 689417145 839711602 752603106 850088825 297525507 514504605 805785417 804828…
Output: 103851

Constraints:

2 <= n <= 1622; 1 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
The Gilded panels of Quin - MEDIUM Coding Problem | CodeTikki