CT38773

Porter's panels Reckoning

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Porter runs the gallery at the old quarter of Brasshaven. Today the books show a list of panels, and the numbers must be worked out before sundown. 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 <= 2361; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 1411 -855076 564984 -142203 -288175 -452314 -32158 780604 -249947 -682829 366421 -188204 89704 173712 899067 -295104 -566124 429267 977630 281267 803893 619329 438153 8674 664032 -932541 341848 -766746 685165 -710055 469191 708276 53078 -958568 271078 -603892 571577 -499357 616926 -466936 -532448 59847 -907978 -234655 54477 -859141 -675548 471180 -204663 -99192 -937538 -660849 -539100 -725907 979178 -628476 -731291 899211 -762394 -253183 806337 -859609 598015 406905 -626166 -618284 -280786 -274373 610253 280011 58628 -488706 -647308 -717940 -758567 270666 -216291 330840 -8121 922015 -551618 -479379 899378 727886 -382035 -843764 -129747 10160 -916029 512868 -30453 38742 -875072 -335573 -598508 -235411 100498 -513798 -603622 324529 -526720 -224448 -908382 -62852 -349196 -444215 730508 -91922…
Output: 163326

Example 2:

Input: 44 359378 -60120 -932921 240831 -52444 -651910 -511780 407556 104039 23366 385471 561249 158662 -210440 558095 -577373 38335 -596836 400647 -80612 589135 387066 907505 154740 217895 611909 372444 87180 891758 -182158 -9527 -341167 -476360 -192972 520152 -139965 -510303 -112182 87709 -163347 326832 552546 724322 -664760 -4039
Output: 591

Example 3:

Input: 1216 -754324 -762835 521212 542385 -452107 64985 -996715 -541393 -958151 -126755 -847728 117064 397720 -318481 336797 889423 -716625 -59607 347922 448924 469379 605784 875033 752649 -327446 -908315 -739943 960054 -48837 -47681 343777 700454 -316456 972951 -158842 339297 -680915 -442362 323733 744943 -774353 -32872 -555688 -554727 380095 -811593 75588 250772 671833 -671043 144527 -39581 -816507 422111 592499 -312837 -679268 -106845 -590773 -971879 123503 440563 320919 -397235 -971374 -607333 252388 -336855 67023 73907 804439 292628 768305 -412396 291914 438033 804282 553860 921312 478016 789976 -13230 126412 49809 357556 2921 822459 -565892 192815 -84378 608574 -978621 -520176 -226336 -754068 -989789 189686 -423881 -970007 -887660 410656 560549 -138233 -306886 -675500 -903869 -97975 582339 …
Output: 146310

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Porter's panels Reckoning - MEDIUM Coding Problem | CodeTikki