CT53868

The windows at Coralcove

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Cobbler the accountant watches over the island market of Coralcove's stores of windows. 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 <= 2479; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 371 23780375 478515474 870505668 255958033 767266597 197660337 554946541 61035496 682760039 868396150 223888028 781740830 214614037 263433735 913170311 821161223 925860143 760058078 668127029 740156400 264933284 78981934 631847577 365281685 280528567 829361011 658535310 201700389 163018316 9787249 372913273 692059387 410540183 882053183 452358334 593281498 653764135 196566010 812523343 379018284 74767351 193898682 811704012 395668194 813859717 427094103 800527807 283213730 324847772 785219309 71037381 492235705 841124060 723135045 216265174 569636257 691752929 329666922 79577351 357321132 59207219 761642264 942689220 827205137 334479103 80712790 141426578 965360624 977150208 710246931 920686328 463816504 842654984 464040597 781876274 474224182 230318668 93103360 12038483 291596217 88970871…
Output: 20

Example 2:

Input: 924 1556089165 829735913 541559924 845413462 485594956 881477418 356734731 177892460 402926577 717674364 281865720 936208378 143099733 563250423 348167153 743987848 752418034 609344130 4816157 883031193 938310757 602745953 86378392 851895118 117660618 526907480 190418574 490111590 669090286 248258473 623483163 288063230 621983284 389111809 765642983 464553602 851904223 701024553 825525802 597814157 832828625 761357137 339806838 46262086 797319786 423344918 475598693 871805226 322761746 948091933 729969508 978535110 640250441 652302776 684317732 816235061 370214979 36362065 234547224 330548382 645190646 638400173 799312137 826374696 958282138 177860951 885065567 82954165 716363491 88064558 930242806 569648614 269166907 534180603 433639351 764833878 791060012 158539271 915752871 922921579 99…
Output: 380308

Example 3:

Input: 1308 1722094000 15490426 650284152 510300558 708271664 243059120 176116785 72720836 347328176 618138178 392555132 484281088 306116774 359749586 739008314 687398501 98562551 97487258 859870201 839472939 542673369 814964011 562952947 474482332 648988785 677682974 443105426 770596209 571944695 603199558 523450447 969105010 301160636 734746903 379193393 88978960 110388835 888616705 709479216 467920051 77620648 257000050 243680017 758879158 940940556 860634577 18175987 219179530 940690572 299115872 753390136 860583612 330080034 591204950 630998052 692028234 847913253 198227757 794575096 8102190 565608530 780604435 618732982 462878473 589058771 971804963 486640459 859939116 319862878 15558595 504980994 614863099 274279790 26337550 553346472 698680659 464777071 668387303 72402037 297534054 574974…
Output: 822230

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The windows at Coralcove - MEDIUM Coding Problem | CodeTikki