CT32365

Chaplain's Ledger of ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Chaplain inherited the depot at the kelp forests of Tangledeep along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 2737; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1699 1656346389 673684210 373610598 51398326 317178031 38606116 700481457 652867983 208355395 813020502 683893943 62618348 206263590 368807575 498640638 296538172 524842804 50578870 850461289 277856011 699041790 708654925 241494171 991817466 767287088 642749773 594194830 13355944 988030070 968102588 10935334 564092075 160072303 988414962 738040463 502936583 735012854 81761029 379048553 419505475 131433029 842692014 463909922 661217380 901735188 225584276 270997967 814294586 107660067 122429292 808676591 867171021 887647190 214281775 637609157 96172365 141319104 873978575 732013501 696110456 177627302 901336875 314417811 444211883 15825660 330970263 949038843 545742954 489480663 23205979 419681235 373451918 919312391 635568697 73265621 539994618 359414372 722413620 647110973 59643561 351730…
Output: 1354492

Example 2:

Input: 1792 1151934610 746147999 548956191 599933194 801349275 813033768 590394576 63763616 26517694 422931066 807510984 174357806 192685014 133009572 997255551 227037678 637052941 748995826 662386792 497861431 455599947 672354263 726940608 819052650 121936474 40525859 959055452 994404718 819647841 592684416 798399796 551039165 47071212 864301279 4702976 378084688 226575543 566601190 347142797 841503482 415801729 47700225 10328528 813520845 379467585 967501068 434716556 402605926 528140029 337743360 365072171 395058513 947381356 493915257 716276031 47865565 171407986 394205883 479661180 804321676 341685988 215617537 432085386 1421520 663203067 759023257 920290613 647633072 121285901 481385482 512176697 538317531 683472769 458125431 315304814 502649736 239927269 102571977 929738082 868707849 94212…
Output: 1047570

Example 3:

Input: 638 749134113 861003642 367682856 381448563 545456417 217757417 64022985 123162154 235259347 254451827 949188783 477717969 719131983 741374130 912375673 843249320 713529933 175725034 490016065 168499881 27347016 835027666 183504663 924754574 875674262 168953700 305443987 443987068 987238693 845472620 11653605 845501132 263868629 325174970 507557488 738726278 961177052 47119289 186824758 940453316 379134134 342922222 141374558 779198121 748305664 591953332 981401312 822142043 815418957 228429766 189356546 596751328 734086698 453570648 123219733 783130457 719831765 777953579 95607492 395765265 963667796 104238237 168712549 735002097 28586239 168721834 503642441 677924715 922911458 102770850 870894853 231625891 906850133 68320114 812708227 217836888 562035127 577492064 864446826 858927603 365…
Output: 57724

Constraints:

2 <= n <= 2737; 1 <= a[i],k <= 1000000000.

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