CT30836

The Indigo ribbons of Quill

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Quill runs the greenhouse at the island market of Coralcove. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 3036; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 179 559569941 213151025 720679795 886236275 408350521 761182146 687496674 820684997 24169799 881023850 731914662 765692400 866933766 500417791 437503154 181129820 256382668 999020051 490555647 42814253 705640064 569968907 456338300 777625928 759216266 61042592 291226933 730331869 147306737 522668654 776267 326826592 214121726 719143964 6764779 469811994 728012556 80413356 484990641 451510649 400873081 445530720 124243478 123587580 134354012 814486995 460412003 872830478 223852267 124947050 295518403 984599167 94550392 493333910 205013762 380656560 460294319 501880447 88298650 528835418 856974771 961235539 843453118 855396581 537049952 72575652 969045038 616493469 363568711 704358149 472480728 471716357 113817715 389475734 190702502 556000203 729751859 286729487 213105904 69623272 856119166…
Output: 2604

Example 2:

Input: 1937 550289745 966274983 417311487 574347383 715679237 163418883 971152090 166837650 401843999 528499016 353065634 325334856 118930927 982532931 193838386 403329395 896580242 802965166 435682513 466592552 500466659 797865625 11997490 255345490 870630846 736898393 352904582 90303090 287434382 921012100 341348267 328760344 15472567 656299922 212629075 680585407 981589456 728362358 862518255 907710112 981316086 455796373 439934158 779421918 476510684 582677144 608568411 207876868 589975703 337427740 268552499 129750686 287083708 417778692 450072096 700658949 952422447 367831846 133382830 180599744 848022686 493417191 830056141 405782931 356197182 264220698 453154849 519214747 155523798 577717464 317879446 662317029 662172670 659711571 379854510 883244320 672800833 47179209 842231562 769041724…
Output: 273239

Example 3:

Input: 1969 1251992644 938806708 784681760 180970222 267720499 616805433 55795096 589528125 941139551 829421743 862391602 960757332 156840795 446508281 143062762 263037797 46206494 276409435 193133064 781607334 182301784 976389659 872166620 225441857 524365221 629411352 104959954 982821069 503576320 484085436 631272911 52740824 866017412 269160124 111285977 921029903 251457969 524848082 832721260 854503925 570144488 282783294 614442398 581545001 915494547 313441422 159531225 990845016 81184796 305844947 635591850 220425901 420370090 738383679 308720533 527082914 95339562 494305671 672637424 645428265 580562163 418046675 331344796 181493675 500773976 651941489 334936865 522825104 879636573 352666133 29657661 49069479 857949227 15417884 525897106 332139769 45470265 122083761 996932939 477824120 637…
Output: 1405391

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Indigo ribbons of Quill - MEDIUM Coding Problem | CodeTikki