CT49740

The Frugal Pairs Beneath Lodebarrow

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the silver mines of Lodebarrow. Farhan spreads the ribbons 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 <= 2443; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1700 305161158 577288890 682719831 286581868 889071879 370076649 765539627 277398870 454128209 683880957 139013841 13555463 510916265 600181744 334106525 200550306 871067170 529228377 459481029 92997832 806532212 796518767 776581471 129959633 90034174 835667281 197924517 441255783 466520631 633966940 590063716 898490907 205910999 123248818 605488463 661033745 823333503 326594486 805786292 47749690 198411461 820515455 698520269 319675303 941140576 203219353 418711008 929187518 443556776 503503183 847919893 587560157 55872012 328144619 818029622 99323865 32926856 688228854 436390848 830259467 730415970 559722230 14682418 383403380 44608484 122817584 226223045 594290032 32161751 278671682 295124708 62818537 994823635 484568257 218301672 838699279 56095129 649469869 886434208 987629839 4112558…
Output: 66660

Example 2:

Input: 924 1216874923 710526648 826803631 634912249 547103551 272438900 749143 708583003 730727949 564514618 251675857 524626321 78133860 283279775 756342337 178274035 412110893 112719283 261772553 477957923 739412903 649408878 977024330 764258065 177098265 464776926 660499988 116154075 451886426 770410160 415046798 76279666 470303347 274913900 523468515 959824175 391611614 91458543 676782166 895387314 683478892 248969211 428611864 150403088 966582053 894910754 609073017 431565395 281021583 282314643 100699875 301099481 481326562 723915294 789862983 105759143 824982602 522907225 743469343 961780581 848917966 598965644 35405850 350340517 167447536 768322356 599382693 746067175 323334233 95659729 980746546 979807425 621511032 441155399 141909176 480598527 140334208 67118557 585856710 391382043 6987…
Output: 306010

Example 3:

Input: 1025 1199163307 104329680 80618318 931510439 168985032 642484836 525417804 84515544 325525040 941752294 347310867 454072481 270804939 893630112 203589760 507260249 225809106 552069635 489468303 740837240 114800462 219871608 218388104 53019818 291135404 983461003 17871270 880262024 481184649 383690000 363198836 752159454 402070725 736130597 547329194 188930857 659640010 265325718 340746134 891185931 46653710 680171691 645173139 310625503 844287555 47562494 300125683 264687161 356991182 924120914 493780968 225917464 657737031 951084186 480093972 595607921 794989541 360779244 52612218 777849714 957547964 571905616 231474218 81893860 24041680 108293773 106022760 834689680 893327161 564948470 609562988 165199038 883820545 174028544 216627068 71645210 376758288 652958318 79197317 285746333 89870…
Output: 370231

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Frugal Pairs Beneath Lodebarrow - MEDIUM Coding Problem | CodeTikki