CT46323

Gita's Ledger of panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Gita the store warden watches over the coastal hub of Tidewater's stores of panels. A careful computation stands between order and chaos. 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 <= 1485; 1 <= a[i],k <= 1000000.

Example 1:

Input: 250 1269292 754827 95000 735433 469941 110798 962192 820041 734684 331886 203821 160285 452418 921539 280242 751418 893503 5196 572117 192157 33165 856495 228870 542104 374078 683261 999036 641370 198126 490406 525137 801975 319495 569872 828456 619479 741213 494174 71753 686487 334892 783910 805958 83243 181787 33274 751677 798383 460273 135523 344937 809628 406355 190803 647312 4588 704816 167548 250735 184590 376638 795632 86446 235142 376237 598927 313331 288709 546491 132611 424141 851048 202839 70331 933564 444488 366001 231281 423793 501195 859385 599480 169415 919991 81862 556073 358276 388566 118735 311166 163826 190499 407217 578706 479799 546534 454509 814650 239380 14873 973835 204507 93617 447117 784510 499448 190581 754966 490355 699654 99077 407957 217121 634257 739809 35015…
Output: 24367

Example 2:

Input: 646 1853819 978435 445807 42947 640572 693227 898616 821540 964978 39121 442670 357562 393242 358629 307317 575247 203980 800203 70316 646315 608830 842767 694886 497445 500292 647319 757074 283659 791383 633283 806627 709010 598674 91973 153854 259295 377292 780890 61742 861886 110594 518585 749365 23272 590696 423088 972633 844696 477068 725210 473561 800054 1036 876175 422568 655078 404551 125456 426160 759989 869776 835212 792162 359140 363728 571089 771118 619741 913550 26858 661461 702981 936247 819709 837504 761903 109156 679231 318823 482464 839766 792510 785133 282546 198852 232925 156320 306138 626414 81827 476658 757020 926693 586148 442548 774164 189991 709952 86343 606508 27219 332200 983486 711900 742792 414794 897700 749413 330066 398981 138939 17515 543937 738252 422464 776…
Output: 206652

Example 3:

Input: 98 1613630 865348 918889 537576 664098 59689 407043 48102 382715 620989 536492 609566 875837 8080 698081 867160 708711 615338 775829 20130 604912 863982 233686 27154 172380 271048 575893 90549 582687 53866 984196 825379 379191 572823 380188 556720 790893 834542 120137 696294 381522 845558 246491 265807 762040 633354 562617 536950 265383 905921 769721 785840 394512 673734 995829 347547 223893 305283 328300 359166 63044 283108 898398 112226 485061 660221 495861 603106 92983 503006 226125 994236 87946 795245 23495 196540 504779 828025 939768 864116 717004 902541 655674 376641 931499 991178 903743 393731 639539 493076 407457 559554 803097 757431 587006 527546 701582 721846 507743
Output: 4341

Constraints:

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

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