CT34887

Kate's ribbons Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the desert outpost of Sandspire as Kate unrolls the day's manifest of ribbons. The tally will decide the next shipment. 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 <= 1047; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 735 1349812 -653807 -801496 668421 -67086 -77040 -592372 -379651 115819 307262 212010 -323295 -529991 -512039 674882 -504339 77270 -917349 -947026 -459807 -974513 -236476 287457 -372937 714122 594080 854439 694551 921006 75512 -577297 268364 -255331 -277902 -622201 193600 322644 -322082 811328 950607 976100 831743 -114688 637193 -302667 -116558 574520 518755 -536924 391703 -706258 -378131 -209234 576701 -653595 513082 725507 -828148 372925 810534 746749 -194679 -590419 -549351 841216 -532615 494001 -600555 -345948 -835040 232211 -209663 563026 -923727 -895753 633847 293479 -715527 823022 716805 963793 -326990 979346 675341 407033 745918 -139627 457634 641912 529528 590641 -452808 33043 115905 -352349 405897 774961 -903162 82935 -338359 -148737 692143 283386 912151 -390935 163223 -652240 -6…
Output: 254587

Example 2:

Input: 514 425053 550067 -978145 400097 865011 -412926 885166 452452 710218 -685833 -90516 776302 -177508 -783862 784055 881284 87751 -190121 -557201 -874166 -935621 29917 815600 926075 920110 -575487 -959574 160646 -276365 282328 970146 260247 465510 -929029 -839305 -565163 -857435 985039 -483520 629099 -145441 -400484 551237 459501 -6390 356035 -62532 -428585 549829 -97115 -811167 144272 -603499 891279 -152435 94373 164329 918780 310480 836974 219437 -998945 -713210 11775 -906121 91403 444309 -771657 285769 -287723 901063 -474916 -387090 -593437 -693954 -634852 53051 -181319 332181 250075 -284317 892634 -719366 -943941 -703004 -324711 -298038 142359 -692585 -246851 692688 955907 690792 -671909 879209 -113652 820873 110810 -238542 544258 -623469 -769853 -908977 -148454 515197 -74000 569725 -2864…
Output: 91921

Example 3:

Input: 944 -891656 -763434 -103038 -35596 -181159 914148 -807047 -236469 430696 -52189 -838176 -716234 560659 -132618 742023 -247779 369608 893649 807467 328761 492746 18930 -150206 -718537 853639 -455946 723900 888654 353679 983560 -486192 907604 663597 -201359 -724614 -930485 125640 -786494 649191 -172250 244058 -995344 786454 73787 945105 -197762 825828 -402192 -135574 -858747 -12724 734451 910181 890924 -929495 -806775 -125626 -828469 297361 -629568 348742 436291 -109334 189445 -342425 39041 -641452 217457 -896029 268403 -335725 -240220 204476 186160 -765662 47629 -341745 183722 811188 108089 11212 896345 -586163 808767 -241274 -258768 907063 39994 744833 -561391 981957 594115 -643257 495358 -526644 292907 324239 -579899 842394 486855 22978 481469 -93963 -882629 558205 -186459 -91589 -905471 …
Output: 63640

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Kate's ribbons Reckoning - MEDIUM Coding Problem | CodeTikki