CT31283

The Frugal Pairs of Crowhaven

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the rookery of Crowhaven, someone must prepare the guildmaster's brief. This year the task falls to Wheelwright, armed only with the stretches register. 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 <= 3679; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 1822 324714481 59372387 575609323 641910816 724158473 811160434 658891294 372122605 752682533 179690479 354874983 531366139 346580960 338217595 204004685 279864834 25161042 421113804 181896840 258752684 93519706 137999646 625496081 731941813 130593911 835025696 891117469 882591369 219400963 668612628 763392703 873476998 531149061 980533786 431652143 661698501 62451405 920442481 956399195 234985976 122745642 454993866 973665946 134112149 559622700 25296142 302812344 29385986 868864541 785040738 325544138 509330027 881513985 585037014 597680649 479652719 711944718 273696546 503566932 395130579 164161441 92511207 971169911 523680443 542095896 859234401 264026728 999916231 754896209 234349411 521984130 952955077 424013621 702839924 883071530 405673755 207743637 947269104 534986321 919670763 70…
Output: 77169

Example 2:

Input: 302 559741088 325361534 5504264 395767124 954121886 638654510 451169870 175496895 409243070 615004154 902755559 640153650 963683058 32769766 523327274 182222756 951807808 462917556 797201761 125459293 383400644 889385517 106114313 218124870 90901687 268783814 736766397 177429034 569331152 557513942 550942388 628885277 5995014 148355307 639691175 511910480 719817311 380234382 269228533 254621793 209624147 239417434 289245862 312439750 780633539 884136309 714317241 324643027 347545321 644593227 607658222 192006781 104533207 417898437 376403456 970340439 501795012 814485267 631939646 288868845 332913746 110846623 322097841 86721328 883899907 366804689 324272367 764190638 627849538 67846249 541933039 225710770 962631536 612015552 720833981 857451058 307575363 831028982 264923022 947580137 9554…
Output: 7541

Example 3:

Input: 1795 1117817313 600998328 674092731 313177236 981641161 257626322 761995062 943571077 525062681 640721770 309150215 966483834 816880812 72791221 913238057 792169494 802310564 325376221 317660050 217416921 399583579 406556460 984568858 670871678 700677774 725959757 806191575 944481719 50651789 555688838 474863408 971705019 522967763 565516225 166067873 333240739 427622535 841279796 832826852 422482036 436974148 517179671 427829699 797955902 179276000 314885232 147190496 622282102 280609311 93742962 681343652 600342886 735889090 130183811 704544932 754807396 946368592 245993342 140490844 613133604 732771920 818656114 42562037 779408996 186997201 108477842 512829186 956467809 941603576 26972048 765780206 667699427 138666645 716603021 193048296 660177599 8983328 909983459 816184591 383383099 1…
Output: 972696

Constraints:

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

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