CT32246

Secret stretches Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the kelp forests of Tangledeep close for winter, Quin must finish the stretches ledger - one figure at a time. 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 <= 2426; 1 <= a[i],k <= 1000000.

Example 1:

Input: 373 1506301 378983 60839 846633 14340 684689 634688 487884 221579 556423 413645 459508 956661 982348 864522 947223 310437 953513 876201 68912 189880 516380 686971 145736 700764 77688 252827 174976 827068 329400 354731 622410 163000 465973 845873 755406 961650 695598 381205 588045 955580 162129 924253 458071 724000 304086 832846 648727 175033 197702 887191 300696 225172 851534 776431 689649 255390 237985 908469 990127 382890 122870 308777 792059 622435 656123 829847 280384 436994 227357 422574 461795 586468 204843 757930 479999 491059 418117 658002 967835 991021 794696 873252 24314 401303 237667 345784 275994 58064 844744 482714 39615 73356 397983 831450 529140 358154 856856 373765 33029 660211 822966 964565 437836 761683 541809 971004 296633 196761 91827 359979 725065 970772 505389 625253 …
Output: 59534

Example 2:

Input: 1622 929088 820009 667407 418231 742529 964043 259159 181704 379710 113289 289585 453613 62069 63366 899519 536773 570664 514387 961264 972645 750279 423318 429979 452740 542062 997338 661768 931786 318713 753342 213852 711940 668647 666444 865721 958812 852615 533799 85856 942561 269530 778333 514575 970540 132647 864919 48091 702559 799340 476167 312295 3265 846907 200882 245156 518529 83231 567199 492342 364297 886578 174864 935600 969606 415270 103505 671944 298607 699762 956692 929930 233436 941853 520589 598977 378009 916928 586809 541110 611406 807417 68210 628589 797035 203397 600135 983381 966716 471639 612521 797361 214552 260847 496869 594911 279906 382419 101784 994589 147306 722146 390137 484424 682830 415942 590993 191232 628100 612530 974577 318851 659432 229151 881509 36844…
Output: 547007

Example 3:

Input: 2156 798275 675491 123610 303146 894116 471397 746455 657940 729954 90470 701067 332898 562198 179078 275691 161287 229612 953801 534765 134873 558502 259749 485550 489576 3878 353949 263432 687036 697925 837356 838800 536493 908765 245215 911729 332297 455437 39309 892553 299923 552450 133294 937189 179042 853058 398739 288579 140183 134727 683704 861955 226358 996909 85201 268086 692380 156862 474439 270266 388836 301859 606707 733632 822199 63719 964893 460904 194721 961489 387428 216664 112432 806908 146154 452665 576785 721294 655301 322659 511898 725564 95677 789259 159369 854132 241565 399785 821086 250478 926211 294366 308530 468342 897716 37696 629385 958526 140469 152646 705930 639756 884017 875314 865965 793807 773119 470976 513912 119051 912199 74985 236782 750214 118802 820715…
Output: 746652

Constraints:

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

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