CT53776

Grey Counts the ribbons

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Grey has been asked to track down a clerical error. On the desk lies a long table of ribbons 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 <= 1678; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 1377 782463972 963187904 837245471 391275445 987265808 745906549 847312116 525861965 164523621 41725305 119538200 763710961 213032011 181817105 244184414 940644791 5471592 28323963 325597210 983997465 460862758 5905224 881214165 992759339 560298259 756639344 713927757 309272349 415331234 144956345 258126054 623997205 119602905 337648258 422940896 314571194 888762851 34223414 58615651 803228035 714229882 585307827 918549725 181480812 464136731 206701687 704025691 322622281 792613709 279594187 983013266 64000245 381789562 619428883 615065262 512083134 370824841 34033795 296649213 94066827 21450004 700116977 118305767 465404230 773315298 790858394 681509650 635159483 694507043 876650427 498490330 352554102 910279460 285299909 24394049 460819834 495817804 105294985 874096081 480777901 26383549…
Output: 292694

Example 2:

Input: 1659 1900467901 450392422 309695638 767497157 298668604 32346926 176723128 700098967 810964188 819273446 670611501 936519665 865999121 606225415 58268170 794798884 682089398 474615498 629289512 630327634 171910350 901049253 736019919 993817897 887167494 546289660 955621166 297006347 517130178 157065929 510114336 491013078 678242881 322491905 472337058 948423690 419188008 633895591 994822041 411501444 202044615 52153253 151579285 673345459 653151996 199543190 701370069 15353288 105400390 754651416 710222562 705220167 635675548 144407595 982155789 494918629 641802635 248582254 427000443 365142941 869420655 506009967 944862266 642730895 150748474 86575317 987813962 431496139 967540632 13982153 180116177 352458251 416240374 303081940 830349970 777747053 297790459 687688747 416122207 223450658 …
Output: 1366547

Example 3:

Input: 728 251128948 646379641 614164783 650043674 873284683 444726284 321410709 224465521 966874091 417791248 7114507 903335909 384538145 898830493 731256589 259524112 527626 977743230 210902884 432927144 615722113 736671491 691284188 258498844 23468827 535729812 199777854 864193814 902784581 330966497 453669933 518653057 439368689 264743756 331083531 751310655 832676332 359224006 48044919 659148488 493479156 232962663 785953331 979418178 132650765 449992793 417042201 26847378 996525912 969161520 699676612 627388418 314022845 653642091 171032080 426816626 161086530 192388660 761977709 218086907 491228884 402017124 798962748 132716976 347119002 168590112 773344955 535709291 877824591 254050774 630126592 105743417 930163708 400001913 379787241 380581481 180336500 502520334 510741113 205080691 9137…
Output: 6169

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Grey Counts the ribbons - MEDIUM Coding Problem | CodeTikki