CT52994

Cora and the Sterling windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

At the lantern reef of Glowtide, Cora records each windows in a worn leather ledger. The guild wants answers, not guesses. 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 <= 1362; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 689 1946362590 962035039 43718611 549667515 45887638 959388713 679105743 470561378 943267313 204202946 139681138 797440147 888785801 811566178 446314590 157793279 575569048 685070479 814256011 429211760 240372250 952538093 418372555 407602002 460808005 892340155 964521820 923381504 749093370 181290494 721792453 458033412 576970194 182707483 866825999 204056699 230247636 859433081 429877567 178228524 603138542 590463337 77422464 697423786 902003857 770574446 944088918 983139725 300854919 899980412 80291204 866214059 599362715 974697023 894911740 478008961 891753521 499484543 517367626 492425178 161496021 257966887 478692537 262764919 168436152 12978959 226207243 996465446 525530985 750238377 479973474 678503833 19089950 832925849 339788358 841485188 56150200 657253455 905597669 497342505 87…
Output: 236545

Example 2:

Input: 1200 1835061249 713938772 423684485 270183754 480243371 406139408 173088553 516967841 269485931 729854180 747867119 360864570 799141216 462118970 451420702 239115012 680782960 379691712 505910474 791646672 33441000 209158305 395598429 415707797 14900019 249332127 325615055 704172042 868827016 551546071 23715789 352083598 617198833 373090245 764585994 927439309 51116404 829368086 1103456 500997667 641917013 779375479 718402651 840355874 255488083 593459930 447183345 222912103 733029330 881998004 357280796 83806074 948945986 9146883 89264970 992773044 487471939 14383241 206489609 54882826 561353644 11801141 69328951 129349183 746805547 191396428 448767976 138442263 821691801 74778988 704929269 578517971 631903262 726677665 598733197 183620985 273293200 444497987 18607680 225388491 613390728 …
Output: 709652

Example 3:

Input: 1187 296623944 931893013 167198028 909184655 403634642 818137740 449475575 61815236 856420976 809611721 20170035 458277194 996401582 988536397 367625028 933471951 505960699 307300658 273178434 762327082 839255061 945124109 139293920 742280710 892475704 58092606 714819707 11376805 681806530 661349850 911069578 539664444 625274123 515333881 470413765 657879325 656478234 779701298 741102230 903013945 61510660 409487392 961334412 986644489 817993406 647191668 833290173 493755770 882388313 876396223 265022077 406431678 320200905 820891938 323916025 53188325 605847912 533905187 189810632 310784276 435526099 389273448 244795197 746981524 516476885 778564013 565999147 14222467 380511838 76839250 545460394 19876518 317343931 333894936 83637578 357827012 944049088 343456177 82054878 180332485 585991…
Output: 26206

Constraints:

2 <= n <= 1362; 0 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Cora and the Sterling windows - MEDIUM Coding Problem | CodeTikki