CT40639

Quin's Jasper Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the desert outpost of Sandspire with crates of windows, and Quin the tallyman must account for every last one. 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 <= 1174; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 761 1824051248 100693406 349102790 768062951 367851636 939464932 771055883 383430351 462559070 153753991 252408778 392572318 958198267 575268073 594004752 909374224 681527866 146579314 24759268 74046658 328556798 937742274 458786175 631663335 710898875 956864354 755579676 480091853 711693604 676929516 632531033 819286780 528545380 248405294 294819295 633361028 109978943 982547523 408917337 942472015 346671453 92048775 821073174 322855710 70985244 696120030 860846875 487595074 173302924 869413014 724527809 743304103 248273528 549323853 838793666 367052318 138635526 942276733 583264843 321119072 792634308 890401896 2957968 888484399 216873812 87606644 583854685 933555109 248140225 958936518 797290520 441220630 861136679 618722736 878875084 978428731 157525258 92471676 874797790 491446947 135…
Output: 284790

Example 2:

Input: 1091 139169124 673489522 959094500 380764580 992689355 612254279 477299709 667848578 156501477 809083142 56556643 807461019 249613454 462459962 448321323 788817308 591790945 77644148 447900625 542437819 442539593 51031980 891303842 19516111 453330696 371852869 347851500 176851294 759497666 21076872 207573887 551747373 731246311 661868980 981428365 994496803 308743999 484625518 126332094 383152702 6323298 377440318 990385713 86536452 485462536 169665759 330627298 911066629 208295950 897317916 276244122 738716573 572513251 513470973 492721568 299088734 964050518 249230803 314180694 273853110 563598956 8317265 378985375 492658495 43239794 281819422 209341286 380012922 449446445 362438256 232337009 985864802 756974589 721623356 974657764 590018845 639992553 805299775 665332927 846635158 763004…
Output: 6309

Example 3:

Input: 607 999154770 369673660 715593876 781053980 171755402 12899348 771944810 78675022 669882256 206636823 371731082 433392082 776033039 701272342 682727190 235769722 96510832 310099733 145613062 710669396 153215890 580958474 375208959 767943694 144470398 475615068 227632967 231057851 700102442 340021849 941887418 378939262 129808333 931738567 106689778 589577697 752014726 971505109 931501472 814841631 653507393 9705151 183181790 828100458 438315534 104775163 795172949 613712884 250690844 562687397 184881441 92063669 485729407 961587270 762310793 759580462 127536649 531183578 672012761 667617392 29511291 658239156 304357346 568011322 28949409 965293607 960197165 323603147 139963812 303026858 968206796 14686191 213824319 540626537 840308845 291701046 718006103 891910144 456697853 158783301 23227…
Output: 86622

Constraints:

2 <= n <= 1174; 0 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Quin's Jasper Ledger - MEDIUM Coding Problem | CodeTikki