CT52584

Tempest windows Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Rowena runs the stall at the copper works of Verdigris. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 3577; 0 <= a[i],k <= 1000000.

Example 1:

Input: 2600 132073 362950 239034 566664 631797 341874 487815 360737 389587 327699 221871 166569 596677 30749 266540 752129 61746 600579 936370 625639 419468 81415 993083 998676 490694 389606 602233 925256 520734 652707 966625 596598 773373 792968 606572 879309 950918 494702 366818 514230 528602 638324 247086 876738 288728 568727 459536 363799 161839 216505 170647 123264 723625 991957 544628 444072 479213 297068 805600 759853 216734 65998 940988 355690 837024 35131 498095 928054 73287 915193 891372 159807 139450 366047 343587 297697 348675 931374 900073 718054 956676 229233 387085 743877 835155 420810 446314 715548 798361 142482 606857 11234 192928 232510 521754 811191 294995 393641 643912 513716 941516 967081 260205 516439 2454 20643 267884 984925 915899 241629 294524 65530 143223 443883 133923 8…
Output: 25195

Example 2:

Input: 3454 1251305 58637 325664 94170 843706 235622 317928 184681 740117 601536 413545 304497 487057 51013 598622 947734 589801 586361 248207 838046 908847 181442 145716 419214 850613 194105 16505 894640 121146 484898 148094 861294 13079 735992 746990 200916 240330 226622 533791 181284 407180 952851 147980 825061 767154 315745 272725 46685 456352 890419 466532 587015 868567 265105 664968 809524 735153 685148 528530 244789 14142 987376 59554 895705 216376 608382 576518 331246 979067 316153 778172 19013 495348 279743 147565 870186 403153 33712 671371 634006 751137 235890 938475 958239 699488 200808 202876 164385 552409 406999 92036 233679 721823 818141 655316 912160 790923 431714 637343 819808 293206 215184 49311 481628 124884 231546 208186 823474 198126 980613 437669 25388 167232 738634 622764 95…
Output: 4334688

Example 3:

Input: 238 1061374 958463 6427 474834 322000 737750 132332 30935 487810 999748 442501 239648 627966 806703 433126 534957 571524 452558 58201 872994 159197 840832 477362 31873 227266 822332 37578 443118 818210 104667 112409 195199 854979 969192 604145 780912 967830 399138 358527 992032 197363 22712 671814 128964 525286 794789 177388 926375 250707 397807 53433 478388 393594 33257 431793 169476 957895 638520 298155 626392 158219 78017 29772 272243 624711 886933 490441 30896 579403 11048 601616 867272 753730 542525 988290 691495 453385 194163 453792 826778 578548 518059 831761 671124 619288 636510 624635 146990 839892 513771 482080 793072 659804 162071 853569 892206 230868 45983 311288 647170 226514 83129 58418 984095 834407 764884 179904 873213 736680 755131 332810 72891 264133 721165 172290 791402 …
Output: 16436

Constraints:

2 <= n <= 3577; 0 <= a[i],k <= 1000000.

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