CT44321

The panels Frugal Pairs Puzzle

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The auditor Petr has been asked to forecast next month's demand. 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 <= 2782; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1575 1227263310 625252935 889315796 789103727 241631403 927117119 979699856 932247260 214767447 137805777 690324587 855959999 151859207 230830462 479109780 649532825 497036220 806750837 907435794 20001477 941288075 606703722 633592568 477367120 199549603 33700530 419725152 21050129 103003884 745659523 707016084 484950966 417198432 379647538 676197267 596406020 329791759 701803071 661468191 142652818 571695615 888464561 793357661 238750180 314650446 71035314 425117829 728282648 223604761 945819141 95538154 457566254 816621989 522031210 772836016 920340929 396356719 905425254 186646308 470590072 391598240 877602859 713028817 292819867 623483089 426541757 622151964 483263861 921458322 332867752 142916151 38778075 77545909 652276949 31202622 802146431 162312380 467787681 242665254 989411139 70…
Output: 863468

Example 2:

Input: 430 1220889683 722837488 795608267 319143915 750717415 878095298 656349350 155941826 663709234 138844883 884135051 122037059 456785715 432782865 609131668 258722880 768442151 822881544 827209862 262150225 412549052 507459503 825452347 955198968 71897540 836180040 216617902 998250758 471517133 792179143 103393683 824977540 894236654 628025936 830157184 481911612 522079979 267772006 210306959 38205997 74309283 692451908 169624611 848510438 717415712 506656735 286862048 175328864 422256130 507622587 505251467 934444246 40931329 895721713 655919046 770292022 911534233 635923926 427957429 365275111 869287496 301994522 116560610 456153480 318418307 682379192 176094445 689424267 161973853 264989433 20341575 469783710 817708263 97535109 861772068 413743805 341385375 288434528 754978887 956321472 3…
Output: 64235

Example 3:

Input: 2482 782258457 738195620 923143304 124055783 183929340 310082103 545948085 370447353 344824071 263829071 359927103 767956179 157822650 244805770 838500748 372761958 944240521 381866738 70356108 741879232 503199070 883775480 503365686 774007012 458852045 24057306 569085379 2559071 358541054 98587602 757964297 777204526 108179534 208252775 563931590 3777426 110933789 151442279 644677459 174190047 29684728 391423381 357867704 797773080 946565054 790682670 522282205 804760317 905326120 936331511 126145674 249712389 822544674 852613449 295378882 261915638 695440809 247566100 386112121 884623576 884609406 881240131 654964221 869252796 958496196 674175024 365667731 560042779 882600948 18876414 445884756 533373274 727189830 998240582 306959941 755407350 408206380 920066666 68232195 248386451 26923…
Output: 953523

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The panels Frugal Pairs Puzzle - MEDIUM Coding Problem | CodeTikki