CT47552

Ulrica's Frugal Pairs Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

It is audit day at the salmon ladder of Rushing Falls. Ulrica spreads the scrolls records across the table and picks up a sharp pencil. 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 <= 2074; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1171 948001 905633 344214 159344 394111 34862 333498 208060 118932 562159 623156 32660 711803 726515 603306 227519 659324 871326 574617 130923 297837 49522 208314 494667 633631 78874 252056 373559 48227 850058 916576 958434 162815 267566 578279 492786 929763 80457 949692 603309 80178 637031 561823 153035 923695 656371 733977 891154 542818 207608 147675 815943 156977 811698 270720 144500 600238 224324 563242 637409 474983 77989 126818 573240 587121 981527 884051 734114 711153 864209 962307 295783 91042 70890 616510 728874 937258 954092 226841 189138 638797 419023 506181 451622 718743 805873 464379 71302 13970 606329 49567 310669 154069 115432 8547 379286 499319 956860 860461 112308 955318 292682 244436 502740 649748 50050 752510 538134 339606 799647 853177 828489 474910 418579 774968 737759…
Output: 319237

Example 2:

Input: 1845 1391702 78328 465157 682503 93055 956157 464428 201578 208902 997478 365940 207414 238430 951698 829167 622740 315063 112078 162741 822286 859595 817984 296515 254596 576762 328279 635309 917310 131012 191306 677841 628785 466262 737352 506423 599679 272660 103892 404935 45391 216048 195747 62484 858058 891462 540715 323261 10211 772872 722005 753969 103436 433192 544047 754619 932909 673457 301206 410240 278822 182209 551084 17856 521636 974618 923421 946915 96479 527680 56027 462685 215467 850808 198344 985521 474689 447720 508228 60831 835776 351822 204644 433450 897873 217269 242317 648321 27865 160797 477447 72554 122547 110953 269984 611767 725960 785427 858351 110837 157731 794929 373505 82803 250353 536188 299088 447761 212088 233204 369174 617249 277643 131133 863613 959025 3…
Output: 1387016

Example 3:

Input: 784 1120738 195325 693767 31200 91717 523015 26830 914799 815864 670528 543807 28202 70982 290595 40368 499391 66313 946836 893308 475401 337751 745368 622205 641073 279348 245780 116714 133829 902853 217029 559479 68026 828828 940858 388900 911039 29460 451061 509629 466348 218327 782909 525821 663097 219809 567731 939120 75446 446860 406136 349053 354337 888534 102484 213690 946145 151434 895425 192057 328783 699723 59830 210862 495908 245550 629086 351051 582494 800262 172891 913467 942129 166023 256396 138514 2251 330824 247958 740057 39526 330095 206349 277893 405803 82807 451975 870293 404573 337670 559228 902924 115676 155326 259351 760741 831270 974542 241272 940314 464589 226094 354134 994425 589120 408268 296256 28568 271997 598001 11426 119174 677224 619913 73222 363549 836926 5…
Output: 187042

Constraints:

2 <= n <= 2074; 1 <= a[i],k <= 1000000.

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