CT43756

Last stretches of Librarian

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The assayer Librarian has been asked to schedule the next expedition. On the desk lies a long table of stretches readings. 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 <= 3670; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 223 967668789 331946886 384772284 882709867 772911311 337495746 715760210 753833151 213544442 956407906 591837055 818139449 283492567 832880136 299153887 701722167 703607769 817203754 821406637 156722281 891478918 154487594 423158438 269759795 307446964 24035624 885927342 230277239 367908028 713318949 683487487 614902363 754091549 700396590 703382757 439608594 373467176 827048188 198635185 606052030 790731166 206881198 688523829 909850964 614610733 368864794 822253871 620166625 997843156 710851073 63603117 531701474 974903435 506447776 783334340 586166091 928410433 307475378 322251302 726651996 624476759 292586955 708511648 499403588 62287473 339184252 594579189 544409404 910483137 661897612 376565647 106608095 683923879 898272797 738635160 8379169 552448418 466727511 820257691 103042001 5…
Output: 10513

Example 2:

Input: 2401 1305957647 365658585 453045047 40519782 390039422 124605672 710359046 409607529 334896455 535852425 747036593 805648557 452395214 737892734 181876354 751333248 888114586 371356418 505015457 118333488 268905512 290072708 724333523 746745679 328735070 108899714 177115723 409994297 765711490 189336871 93024878 378714798 541456901 530515964 381178545 563063975 4055712 798726813 581592942 992197208 900685565 757325933 615573916 211646754 12612250 427896826 650616554 808522204 4278566 748516986 58607484 443353050 508995461 834664022 214935327 595604249 278769214 719413937 449562277 675468085 840211696 850746933 77951143 578970622 192692922 58333824 369582144 354581110 541146990 431916128 332492637 819897845 453761960 729358220 941620448 7280604 519689370 53857203 447598434 185294503 6865474…
Output: 2230675

Example 3:

Input: 1187 135044955 850524549 878293371 235384792 800350460 490092905 978987399 136638615 852879007 488602757 155728385 724220638 40721120 29765632 693129885 293736129 77645721 281342718 255975124 970468839 217036432 19647932 537078894 765602119 896274376 908129078 568758903 268819020 261026044 273308968 429563806 358905508 350194811 488469477 645818895 57835461 82358583 298967907 994870877 237616047 113281947 65845835 995747954 332337118 376471202 627579624 747013221 144721908 935173879 919827453 5809950 61464813 859744858 64810578 66473675 971503345 681118102 332855781 972906133 135689594 970836414 233364898 529618472 284420949 20716637 770328518 964188723 292633576 833431026 861962413 346643622 34465149 321048716 894051069 416218916 666842594 545159832 899631934 394098968 880817904 955745154…
Output: 6763

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.