CT54845

Finn's Ledger of panels

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The store warden Finn has been asked to chart the migration season. On the desk lies a long table of panels readings. 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 <= 1229; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 322 1828403 -308519 -997529 -259073 -252063 446586 876317 -779945 -977025 189367 -335407 -516885 940037 333110 968120 523860 -927898 599635 -94117 517151 720229 261761 -104025 -34292 529893 -719712 676849 -480302 649314 -632339 630322 694909 -121809 217296 -663983 886275 -342156 -714101 816085 691547 139301 933483 274930 497896 -381983 -552245 500179 -122673 886446 505488 173392 -61507 695235 -85077 -50719 631498 -387451 -578632 -29446 -290992 77377 -92830 186545 -572182 153126 -171397 -694774 22495 -354027 -952342 -907393 575815 -39934 690582 182758 -665869 511679 -8498 656185 -461369 207319 -257714 693298 -484360 186756 -627082 915255 732611 -311077 -100068 479796 601786 -594168 243180 603955 659126 920892 225623 -364234 714979 -307857 -113950 -977303 -955186 738922 -129191 915801 -55916…
Output: 51563

Example 2:

Input: 210 145763 947034 657146 311037 294938 597138 -576119 -968141 -628832 341940 -562964 9033 655420 702090 677081 -537838 484595 608891 9603 856556 708968 38616 -141940 926348 -638326 -668407 839348 -663909 330012 -43816 -886654 38506 583560 108716 231414 -822056 569643 -798473 262620 834078 -291751 705979 -324996 841150 363114 672705 281144 -337743 133567 863331 576968 788948 411209 -822999 265138 656202 491644 252473 67801 -635162 -230728 622751 -479433 19532 -114847 -469963 -498145 -160638 174211 598525 -37789 -270156 915103 -637618 -913243 360280 559358 393955 -79498 283767 298960 -305276 705639 272485 -222245 -992926 467545 -210817 558500 -583221 37609 305085 224202 743447 483053 -211880 995342 -658051 870137 -458213 -298567 926576 5303 655755 -347475 318391 -242359 623291 -257065 -26724…
Output: 11984

Example 3:

Input: 1094 459617 -59083 738371 -355201 121166 -707212 175124 660976 -861611 185181 102707 -716851 -172886 609155 37992 -888647 247438 -243212 436777 -397771 -689026 -45058 262972 -867060 -532582 650387 294956 374288 -835900 345322 276651 166129 840688 335637 -897023 -490054 311608 92179 -933357 -697246 -914274 -563695 914308 943970 769562 -553297 861912 -769383 -546497 -473157 -718240 -280146 -46470 -592395 -251618 -816353 929443 742997 568120 -959965 316531 76414 -910813 -556451 -797030 206962 102388 -702758 -801527 -172080 143983 755174 -402608 -511004 116983 676022 974801 -207529 538477 -584077 251721 111286 961025 398450 403092 -238849 830695 405803 -429919 -246809 6080 -757218 386595 -86400 665735 -56664 865770 907574 72515 -712957 769264 -668069 -847347 -910254 -698027 743800 -360284 -352…
Output: 412557

Constraints:

2 <= n <= 1229; -1000000 <= a[i],k <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Finn's Ledger of panels - MEDIUM Coding Problem | CodeTikki