CT54655

Gino's Hidden scrolls

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Gino the customs officer watches over the opal reefs of Shimmerdeep's stores of scrolls. A careful computation stands between order and chaos. 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 <= 1314; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 155 1286117370 692588190 113316541 634842818 107159195 265041334 750175881 106428701 733355815 531757926 513237135 833267040 216012049 879015892 981020767 186887765 825752170 887648892 963520566 868657929 872036563 951933763 654080278 990005155 17942839 125176695 495281687 251685057 760829779 127908034 349661410 26162555 22641603 562408945 818023158 288812353 991300851 16616882 514572651 337652849 542232018 353999695 678444939 311556895 630137199 637098552 420383434 527041312 179474828 353769302 894120827 421665116 97783586 546112014 222345947 19897261 840272687 608462927 737540719 688154154 975962699 284754921 629367071 728384050 991126402 403086653 884872553 874257664 755778307 226349375 69648397 522014570 847439754 301437876 480778372 615395133 238428092 257073138 551708358 723755383 95…
Output: 8751

Example 2:

Input: 260 216428948 805083391 565171994 600443297 651662292 330828382 44295972 129357539 241581071 988286504 178365845 275418443 954014151 388463807 92536075 304082189 986204493 869847873 18181336 423432213 232973248 955854055 924224804 329109053 730101031 979533072 119238780 7414561 824262463 184811601 56439637 629905931 716688243 744341924 384076961 720994987 41239665 515255651 709635961 394025657 133550136 465905772 367742798 648327601 295538617 841682956 692464080 523456779 28271092 238245230 435436178 349697077 330003043 174865931 938092836 753888380 295010308 449679729 463183439 244295757 972380540 917549503 238499134 64239480 494068335 340390897 387736479 677474549 121656273 602502263 851735248 229464754 364655341 974238411 659115428 727874445 520991779 186685505 885848326 635942453 47665…
Output: 674

Example 3:

Input: 755 1680731772 472098267 745957297 403430537 591949754 589134895 448325979 161160838 857453928 173577451 952707130 573296530 933312427 290093015 713193076 389809860 561209669 653427479 319705822 478261681 886704417 609994689 374911837 640812589 746358968 857330892 656282443 148146894 876844446 304325029 843244659 895818759 139443464 586755055 745630290 972079498 21641970 87269266 920133003 207379252 991307302 470766678 263258767 366876730 555035729 834451474 524673392 106462777 225174007 132611690 136848783 122547919 577044846 217136890 38030274 745355749 263691762 878977015 750550594 253501931 778341745 789025891 737217174 793461650 543771656 948661218 265556846 581844679 799083160 162415757 796774527 351039924 946502145 904315019 299298793 437869845 872832267 263768914 223166627 33801508…
Output: 271018

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gino's Hidden scrolls - MEDIUM Coding Problem | CodeTikki