CT33979

The Faded scrolls of Jeweler

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the mountain city of Highreach close for winter, Jeweler must finish the scrolls ledger - one figure at a time. 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 <= 2647; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 319 1456409026 316143699 614123116 907436292 436473348 984838249 286666570 765664870 801486136 685715244 974819332 282277775 63150747 260891323 851264400 471493886 455184701 236341818 859331061 231041948 866671116 203413235 280104677 549182180 908965590 527750388 600660139 743155124 110085693 960381214 477560502 371608604 29786929 251181486 311348447 467787647 563736890 555684371 832587978 873326006 450845544 334250910 376082265 644513793 854575145 19524276 117441279 183096931 41860394 17895456 192295539 344759087 725055503 266612084 555084581 585763897 322266883 269276477 780264448 567823308 595278866 626407452 96242031 633773653 614587736 211251914 47479147 934207290 379561784 92919620 807228865 778179997 472509083 668646107 383531918 634793625 304847726 789716553 917913791 268798956 476…
Output: 43195

Example 2:

Input: 2404 1970287753 74835886 384603611 965376715 37451224 914119192 907194807 327991775 66643434 413799466 900071167 676152509 845107007 604580998 196897583 982170655 91179161 1523996 502928072 691073524 58197039 77640119 908817658 821739501 146702039 288858922 458103292 617363629 863118951 502933152 143255260 570870981 795813510 588846704 959402461 265990253 518411312 438467424 292312851 326196615 134033013 289696400 911642831 592433335 260448467 197948168 276706057 494772706 15165353 643675052 282513892 334705768 237110890 760160791 553692276 437180240 918097609 716557874 850848305 851809907 86861422 14815631 503459753 16027927 93651822 703994368 90215329 274478126 421937419 452514333 194096362 380863258 787437199 982479022 360900931 777748235 571501477 306656518 833300664 442547460 85793903…
Output: 2886909

Example 3:

Input: 966 598089604 252592724 996032208 662581620 450463272 575319313 441025129 524743645 525185511 318843446 717842283 568992912 288050236 670885500 866050000 357468708 230413551 702915140 721119906 721817529 73730816 473403020 77412793 894613095 64930477 937582353 172064891 277854640 892017931 177839140 389165554 584699868 579117434 171802619 124806787 96561679 171292961 851338734 115831561 508723348 935693793 880398821 549135131 473649401 828971540 643103161 686330729 1223960 573641602 6489857 136839929 753209269 108486240 945152730 328037889 453938925 5162839 282126627 292172711 500778998 406886748 631234910 158973071 41801816 387519610 701732871 188865654 259735828 750546220 393178713 203295024 402438275 333841213 131557139 991194743 198577349 220698074 358339198 214527077 301818549 1611270…
Output: 82105

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Faded scrolls of Jeweler - MEDIUM Coding Problem | CodeTikki