CT32949

Smith's panels Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Smith the measurer watches over the lakeside town of Mirrormere'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 <= 1663; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 631 330677839 194026316 299111819 485270861 362679885 415635638 50599427 236256594 724033399 361977636 180613234 793999642 361484226 289805535 772827972 48188590 855161934 130357240 238147948 345810651 544204745 969582398 90530107 833352907 763327143 952744157 678562080 535382876 787528867 504011278 510659359 195757737 861306354 946284236 620519175 455874067 205308404 693644431 333150781 636853509 628625982 380760990 186876091 283271122 226481369 451065411 591401505 259906661 106648367 766051942 219910599 850232 241475241 593493950 300824581 521393831 135785573 950980252 511428513 833118547 390433511 954146372 574804434 471915722 463358736 896248743 135650580 54507838 1198631 620790920 765059266 724271445 468672370 99093724 34515140 449799635 540129591 865245860 73650222 353938968 20666299…
Output: 9096

Example 2:

Input: 1164 316085400 255202556 931444425 779653372 736616990 793468367 848938366 939598625 105553924 137070355 805886081 11497526 172688402 442770996 562616965 454684605 868634932 735080419 83709492 889258772 96186499 988684134 255577989 779882053 169256934 681190557 923364700 377496120 120002629 816888665 355382972 537300535 532709658 720253553 195994011 714066990 1279037 212890450 355864288 747560916 768657534 56312284 659394191 172839814 507429378 690052187 10022629 470438378 391826163 15495947 232236213 404991845 470196759 400157196 534889516 291201509 870986964 450019048 354765968 812527755 649785980 834722128 836983312 225734570 462893271 370068686 837105976 303270574 2082218 746462551 838788680 808636952 237475538 119231185 173157911 600673873 719983878 554051638 645601057 273912466 13038…
Output: 37897

Example 3:

Input: 182 1813823759 38869857 583834852 304855419 948734441 426486020 231568825 670005437 669090543 504057388 526647693 524421136 643232209 678585920 386338735 669322677 734918173 211201598 810771448 863651211 305610736 729555551 203192817 951271087 678055342 484209919 309025176 114771598 684947092 824052560 399048329 576650840 755743044 766569666 111544782 195203068 262401609 575405587 949663272 234563840 959209708 142240253 233897221 43410123 55378676 126555657 694353302 20921604 11833168 535940631 189590143 972797038 562484501 905822590 772056672 440965179 801022647 446519468 579918011 810909922 521711768 766870577 852229532 263000138 611079271 450316441 65168530 252313621 491041608 162993094 317157085 910205350 285503191 493113382 538604017 945854273 580949760 553395304 57281609 287888384 86…
Output: 16132

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Smith's panels Frugal Pairs - MEDIUM Coding Problem | CodeTikki