CT51832

Botanist and the Pearl ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

In the indigo vats of Bluehollow, Botanist the surveyor keeps careful count of the ribbons. Catalog the new acquisitions, every figure matters. 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 <= 3589; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 3300 685281 390009 -788813 788367 -515717 -10542 -671622 -654813 517937 941252 -647458 -78625 -959834 -208715 537713 -894180 -355417 55460 81633 -890000 -442675 505027 -36376 -394279 -667255 -483091 -940281 -916298 362056 -10351 785045 -84914 667345 954961 -511034 435741 -347148 -847627 496589 -265772 479860 -639127 -76069 -681470 -394796 -441488 111463 -275534 11714 -685498 -850520 190480 -37551 -720896 183502 583099 34425 -687091 -690262 910103 -567777 101322 -884992 24913 106122 936005 -530025 439297 -898255 -634297 -431364 954208 365576 -134289 -435047 -159758 -22574 -530114 -695172 -485470 -15029 -377653 -918349 -947433 945490 153770 731772 850099 -421859 -44511 415084 -417196 -680012 21185 -375135 427469 378158 349534 -118244 -357130 -464029 299620 476605 935210 286835 645977 -610059…
Output: 4317375

Example 2:

Input: 775 -277847 -969067 975354 -492018 657412 -330683 -19187 -175944 450976 324064 274210 431145 -80744 169124 259557 -664414 253925 -860481 -708743 785315 929879 600822 316711 593416 379097 -646670 -174942 183828 886988 -583416 -336440 -803524 -850602 686096 212818 992489 -400177 -191306 247413 272088 -960723 -281988 -455460 -721776 -32879 768573 590042 412055 634044 -723833 474699 407890 -437993 147460 96993 -309988 -273281 402824 861017 394462 310268 13811 207136 -265125 -972342 -579673 -19029 -152402 -803371 -908499 -797594 415561 138059 -789855 136068 -610551 -160191 -435986 -995892 -443209 -480285 906359 231780 770971 996192 944573 -722165 -793360 -164827 -842767 -795693 407246 -234654 541602 584319 -927457 648926 389138 703635 382103 -661199 -721432 444455 553093 -303294 -783994 901065 …
Output: 112228

Example 3:

Input: 152 541425 862682 135558 923086 -34794 399009 197478 373338 -964567 804093 196724 -960156 83996 -650042 -236436 488414 -875244 -573320 105944 503794 257182 96206 600759 776366 235891 613589 539701 480622 -677177 -645022 688396 -333730 805042 -559549 356988 -522545 -39479 -526508 545741 -384880 73730 607060 -691180 -368759 168980 814500 -259463 -145358 -101246 -626171 -452801 303484 896024 -937273 585465 712775 -419224 26239 24165 -437909 846644 -649271 411013 302019 -59212 -534509 -8357 -967017 856578 -78676 -966928 541932 508961 212190 -797635 620856 -784796 856445 718789 -286780 84249 205996 104377 713817 -56385 978634 208336 979723 512260 -734349 -162751 -228529 -945376 370113 918743 48063 489165 879615 893734 -203641 707585 -623411 409272 -668619 399184 284755 -180674 -44839 -788561 50…
Output: 7894

Constraints:

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

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