CT34485

Last scrolls of Cyrus

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the spice bazaar of Saffronia, Cyrus the auditor keeps careful count of the scrolls. Plan the festival budget, every figure matters. 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 <= 2271; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 1915 814033709 261888420 83585784 578580808 437997431 575847614 500015625 870882927 4118675 402073282 835997636 671916398 879521014 466306689 402295914 616495285 787630395 984676776 411886530 748232578 140249705 99596298 435571747 477553484 977725847 486138985 265534802 409472869 321431661 406489595 475448502 271812284 1349940 120130506 482462921 183290575 40821495 749184928 988174377 9363195 339243454 430787251 794496075 362710750 533653325 632263135 369289081 271217916 167390289 817269619 121579852 781267713 116353942 345910170 744524667 960552225 916441689 417910099 538657779 217641192 62060212 775585941 257286859 228210770 318359990 631589632 79757427 167865310 484372954 6723478 538359051 661616536 567310964 283089901 828350989 155224747 194912954 69800099 94768415 834145042 833664914 …
Output: 639725

Example 2:

Input: 1262 876933161 752392440 562606063 326838325 668657479 639395866 256378259 520050906 973928994 581404995 570637283 123698837 752224852 273550059 837606721 590202859 212877907 20394134 243975615 126010733 451792836 44427776 347150519 961208171 229389260 273894925 982354755 620016208 391486652 626003660 730328157 110567158 692372253 764427335 463363336 568156103 884942894 898377449 750432838 744846862 583997479 919222024 703991023 793696346 897765081 265608264 825661788 162410263 160835608 673376633 671889859 82061371 540378823 920382805 807230007 707818733 711236943 391006395 394104940 509376295 714864099 257985677 972706679 188971319 2158166 755205640 604028262 343048837 19667878 726002678 216377214 82272414 324747092 240249185 165491257 154844382 899778475 473753386 568374486 782749728 82…
Output: 304368

Example 3:

Input: 285 1477415786 636469779 703896871 292635160 206995261 840501371 128331850 894090179 693893422 214920792 750289883 45312073 706907877 187564947 119141384 373049788 951238072 8005884 615698092 431592858 6202881 689389525 696202924 140684077 102847749 54191728 192354777 845752094 10291555 52455673 265759482 332749335 187526932 453461636 502379068 100794665 993957366 899623972 942480146 536877008 726686999 973338121 179308093 739414463 561025680 841105797 357649213 92095134 896342456 923029838 719232974 903519082 275345026 895473296 625259469 202557571 213721632 935570483 463955297 3259823 369354201 200710790 858463013 467826080 934984534 710717279 695699181 767754121 848694493 675706406 376093446 74414515 543647617 289011509 987244404 960991539 235012849 534264369 62076519 984519826 28392502…
Output: 34320

Constraints:

2 <= n <= 2271; 1 <= a[i],k <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Last scrolls of Cyrus - MEDIUM Coding Problem | CodeTikki