CT30656

Sable scrolls Frugal Pairs

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the opal reefs of Shimmerdeep, someone must decode the foreman's shorthand notes. This year the task falls to Dorian, armed only with the scrolls register. 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 <= 1326; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 235 -432594 -516912 256290 983795 -229959 -544752 301661 -450867 -5235 -726724 905893 182210 -645889 449288 655679 257922 704154 -264614 -876214 -344994 193745 -134802 992478 -323265 -971571 530526 -453661 -482211 -250771 144226 -674535 -119285 483721 817628 -10912 66270 -318842 885227 628585 647669 83493 377149 76216 538851 -753543 543443 947327 -904608 360005 860831 -707634 818658 187589 -752765 -51412 388076 529187 660275 755354 -101319 -86163 700646 -498708 -788869 -84813 -889286 -214057 -157165 -590499 243734 -513984 41737 545629 547610 943198 -773727 -826872 -478278 149804 839567 399207 6042 820693 528457 706872 954910 -964377 -878466 -191814 -968707 413448 -965338 649443 -719419 -521585 -571414 -441098 478433 -348747 -605382 614495 938809 348405 -701899 68857 -129037 638029 -901331 …
Output: 8342

Example 2:

Input: 1257 -274375 290758 902988 151729 -990787 198835 -94066 -674545 343895 -122651 436531 210855 -806499 -580218 -203480 809835 -309553 905973 -10140 298362 -536674 -466673 -674939 -592178 110174 -169866 879713 508470 17718 685692 109100 -144196 19462 -406202 432403 -699571 -394731 946253 315347 767173 -413919 339574 687762 -555638 903928 568920 -906795 9474 827474 -60119 105399 601064 -617971 -226838 -242136 543429 -804346 -461023 -755838 -207317 345127 276469 -38675 2101 -61558 638284 -247365 839223 -437996 972247 89966 -71934 437015 381626 -277446 652609 -542245 743722 872806 -207744 -788426 700156 912423 -216102 840980 147133 771193 236429 104211 431403 269224 -353196 -20387 -785455 467272 -765906 921064 866397 -802996 -641651 -906470 965626 -478007 237256 -843156 -729479 -433533 369989 -5…
Output: 280740

Example 3:

Input: 105 1047121 455659 -418801 142440 -44372 903345 -839069 446308 424345 -182241 -858901 -191960 132125 743065 -848399 -731195 -65741 -39068 -624475 -312783 56830 -807080 -193458 -255814 843679 -442253 199196 -909355 -665931 601047 -595491 545213 297394 -351530 449000 -334366 -109865 -781441 453412 215907 788545 -739474 106848 748170 235682 -763828 -680198 775492 -703173 784572 -792394 74329 -743222 618344 -517104 -419301 659152 487700 -368063 839282 -271188 -47054 720158 880526 -814872 -20766 -191204 -988979 -825008 -751500 368835 394503 -660320 -519610 450070 -265274 -916344 297446 740724 162222 -974219 -676551 -803499 -273908 691872 -126303 -676126 808877 -316050 -841766 -605952 -343472 918754 341360 -247265 833658 -375891 -398719 413033 397866 129059 285808 229122 468622 155010 150232
Output: 5010

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.