CT41383

Vesper's Frugal Pairs Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Morning light hits the pearl fisheries of Nacre Bay as Vesper 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 <= 1239; 1 <= a[i],k <= 1000000.

Example 1:

Input: 288 235806 626511 829996 600759 59804 137274 188329 849265 172065 675519 902662 746195 393824 42968 279719 721932 543454 724835 372493 324620 430415 584366 151284 274545 661386 317676 921173 775335 445539 481453 582622 122851 23664 109632 5319 161288 753110 313942 92530 664097 393016 945503 994194 219222 284345 517336 772252 507860 347958 379251 145294 858236 895327 181727 381769 533709 242879 805512 114689 999496 529519 536234 537617 461473 572487 198736 89467 775179 99162 782082 985003 100969 290377 471480 55807 368775 67590 828618 868247 664530 385865 597242 460452 507882 792668 936398 815041 857964 714455 567352 167704 438562 316195 709359 130979 262820 885339 257943 99205 273075 769438 589538 172362 333811 635617 991066 417088 780901 373608 160485 951671 281650 555046 83679 393831 630…
Output: 1329

Example 2:

Input: 654 1381245 966380 984364 820131 145970 922185 240181 960089 758793 275191 451067 210339 669029 460036 482160 285004 183172 101831 604306 634167 970768 841641 28372 641746 148770 271800 264445 350817 975937 712414 376873 149231 534230 236181 979924 521477 698622 973134 485453 142758 735396 208556 694133 554558 197831 795868 693243 208097 826649 930503 252756 489970 557271 85543 673122 128578 292750 463480 748038 79203 549850 737818 900117 699567 793607 854081 986590 799460 281438 823306 370147 839936 505163 429647 638360 23062 384824 420754 714251 153163 302393 419626 422608 129255 815486 616179 368937 543779 641276 598498 61696 354375 514910 538856 262990 587390 449086 122632 299853 842249 972038 509499 629076 419642 37452 620781 26927 854768 566614 44927 299003 941823 516317 1648 725054 …
Output: 171077

Example 3:

Input: 1078 471883 6944 669223 258749 301522 98176 641072 282929 893945 382793 743610 184898 604395 822987 64234 49619 459207 154291 374707 784026 402152 779770 495426 747078 591343 398062 437758 105499 584084 279021 546096 176692 969945 982481 4000 2531 268921 393288 969973 876045 468007 808017 954730 401120 363982 450224 228523 695056 986841 406592 448110 170371 890054 893338 906107 241721 910297 68401 56508 611814 676045 654327 85066 651898 716028 752594 558637 428501 886369 975798 904092 199278 729558 558364 53082 145223 868914 856913 890342 245682 364429 312797 65525 305899 485138 768029 799647 702279 903124 529803 682285 851680 769183 17342 793669 669199 272800 442932 272144 223127 837569 661891 237723 651164 476098 54034 864999 384498 687274 705537 740460 754549 260044 239779 652094 90376 …
Output: 71075

Constraints:

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

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