CT33596

Wamika's Frugal Pairs Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the forest village of Briarthorn as Wamika unrolls the day's manifest of segments. 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 <= 1967; 1 <= a[i],k <= 1000000.

Example 1:

Input: 414 734332 31437 446156 701448 522066 745366 677031 174733 243924 798528 958622 225948 418897 348570 697804 349407 991765 976473 514475 319960 884811 648558 136878 744807 195661 84196 905452 754776 15200 263116 318296 845448 852732 410879 87112 75655 617653 232836 292284 143819 431672 767273 691171 250676 66824 301437 612272 421199 899871 688966 991762 662690 808559 75268 682970 164711 244096 444251 700997 78043 323173 219788 547521 733827 545432 825907 300480 987808 248225 263516 842809 375058 437157 500835 588421 326898 484578 464019 923817 958220 392154 321909 110741 768062 492477 849298 850634 801642 633610 9766 126122 314640 251811 195929 874786 683947 403178 553713 893530 447329 813534 137492 573730 76069 793574 922502 456591 732192 774543 769168 262803 218888 434893 563315 909228 34…
Output: 23436

Example 2:

Input: 1722 444089 197951 868563 244045 381280 492690 785254 722185 800012 885144 391738 38505 751471 912185 729930 297370 938282 275725 488394 938027 291727 622658 922060 916966 242321 939941 113345 812485 55292 943686 780920 201209 401400 819153 423757 83912 834159 564870 224319 47014 212312 95216 312587 782084 940905 352122 277400 799516 906041 687128 140317 241776 247946 275812 538641 668455 489018 704065 49423 229077 988879 667566 624306 535824 62288 514078 502439 20938 382656 801207 65526 756465 95926 231519 255163 795059 357331 893622 228357 711430 411108 181392 252585 20009 597344 124888 883133 843177 859394 211861 49097 526564 772624 916407 231570 657444 726368 286034 959383 957785 463574 629147 254353 928644 966244 107522 780914 167085 127658 725872 825227 752741 585043 607373 450229 84…
Output: 144780

Example 3:

Input: 1369 493083 734751 690311 325305 552525 901166 706730 240828 166199 101568 937466 899953 876538 484653 245733 338547 794428 487724 392933 583955 723422 928744 235662 896716 981295 31917 475242 541639 1071 537975 523088 216192 306154 532248 385247 17048 904230 975067 881119 266600 507698 5006 480086 816503 295314 958588 371754 948284 35597 25085 794848 523180 267958 706273 506096 580815 651063 19424 844140 733352 129989 368952 680460 843450 651509 158464 513115 436290 85621 335825 92137 963558 333934 898892 885050 392600 111244 257760 773017 898144 475142 734096 291728 530010 273697 129888 290515 13240 537164 807395 451994 902088 692207 307827 435744 524986 68074 725469 417659 179929 945743 646226 443580 797875 200411 614786 140652 911160 113270 417620 704280 691429 258692 136387 234988 151…
Output: 119375

Constraints:

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

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