CT56075

Gautam's Silver Ledger

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the quartz ridge of Glimmerfell, Gautam studies rows of ribbons entries. One clean number will settle the guild's oldest argument. 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 <= 2371; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1222 1029481485 88583282 13698635 882897289 95512272 639598470 299876867 316290782 432078847 169790577 834617724 403342386 479275513 32370782 956922880 649126680 143685403 783277284 463469362 546516672 271788570 591212098 797965380 363689002 816280673 451605114 867869457 908232368 93716253 365876447 167340502 521347272 506746865 578839583 494625137 319786235 26488623 602968282 18434972 913134775 657900667 866198529 291179592 749281433 807250193 685211135 222781217 226429633 176488023 806486196 468556567 839086090 974720743 172357386 308346422 402386043 403379888 264369704 913820290 538784700 231227811 903672414 450169426 995085130 815657748 820871597 975350199 483259109 160073904 920133557 711978388 861679505 236373821 869149231 155062871 270525238 915239994 914417913 666346762 149515174 8…
Output: 402108

Example 2:

Input: 1733 1650396158 261559127 844940316 95465814 200491653 479211255 1371930 851569711 278799410 918911732 819979206 976118010 649856334 498792377 8168394 430046167 361826506 875259427 488057851 643285985 401613827 386073810 157651220 883575157 54363341 231251294 208808022 980100047 74345999 804964382 148318800 257791645 126589013 432441067 60933243 251719426 936928887 980167340 215184107 378904118 91134159 114826502 796338798 778626090 248013821 347451339 958450463 811281674 551826960 531164796 236104021 917623229 818657598 703717232 40375017 922985769 502983674 504388356 357073108 735389805 400784274 104878923 323628756 858426069 694778379 785945377 111256269 951682607 225601633 114978217 142994579 582288736 432933262 368124935 759426079 573368416 717137784 863338444 312306909 30115577 44050…
Output: 1408017

Example 3:

Input: 1444 371538955 871766156 303812289 441830222 545903394 169109469 913305244 986918024 550313865 33660252 760825162 503367566 706250845 331341552 517620264 254356764 525377047 682732310 298046085 641455552 120165401 106105883 617268351 491385146 410985480 518521656 762165055 937405640 614724327 97550112 779534401 577905983 672197201 654498099 295481367 172660963 382708874 938568384 896511267 609008792 406747941 723282934 17509813 954684573 614338521 348469299 956867063 963729705 53139280 906765865 734125224 821531010 855815821 44153425 475332685 523112836 109822931 925838315 160698516 883914126 443902728 720959609 798820974 128616485 268568414 261876190 316529473 847164629 455541481 722830764 4101291 557524055 655024120 862308263 64416588 252048005 812946267 382374408 151256146 989701959 539…
Output: 63969

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Gautam's Silver Ledger - MEDIUM Coding Problem | CodeTikki