CT51914

Last ribbons of Tailor

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The log keeper Tailor has been asked to track the breeding season. On the desk lies a long table of ribbons 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 <= 2560; 0 <= a[i],k <= 1000000.

Example 1:

Input: 209 1912253 716056 838584 349744 493203 798442 145185 854764 542012 274399 978384 824467 786652 970236 69915 648576 268312 976151 797449 740782 626209 494008 855113 479675 599901 531001 575866 503918 633250 996442 960220 982887 835354 404107 962700 149259 771976 486098 595677 652713 163785 295497 699416 718994 663532 727192 669295 459168 648687 969786 244378 191702 14690 353763 380168 370726 863153 549050 381767 484848 623859 404690 943790 161341 63495 225719 899772 576028 665431 276334 784935 332321 292515 805253 357855 493468 798234 299706 144373 556363 353318 193311 659074 975055 19815 280246 750328 701537 283283 697840 588202 931569 295899 745275 464516 196344 335206 890760 284357 75323 690116 796528 392898 146542 251484 621354 227860 130103 934141 536617 838812 624572 592648 860547 51…
Output: 21595

Example 2:

Input: 2331 266934 782357 496047 976224 839006 965352 187385 289874 429646 995423 587316 811630 556005 238001 839183 258683 304489 677801 957592 227213 217985 305590 384564 812790 898704 90452 913122 109587 498942 828590 304039 855466 195457 851911 513585 829723 472818 341314 534754 566485 210034 77219 472850 548556 728881 427874 692898 523366 824032 627353 665259 731218 882625 605286 979911 795388 521179 698818 188531 26832 181230 94100 551061 621262 880201 695805 991997 754578 447533 741752 142333 81016 220668 783901 835677 311081 49994 706475 351126 953760 356971 90357 620006 701879 273459 716381 728375 895796 778018 915930 723917 473648 470112 718533 205035 794483 497819 747735 738707 201669 469840 216278 118707 362799 388954 305690 430356 603711 91344 820102 550000 436176 104730 192624 50184…
Output: 91154

Example 3:

Input: 2395 1301480 749873 435202 633929 301121 661390 972938 128477 793318 782647 691954 679869 961892 355616 589734 367171 453894 584971 955744 943739 86816 782299 870697 787271 483219 83208 997593 93827 643299 950768 466556 113902 549437 718387 34029 407029 550414 788140 899152 603955 199386 629315 69741 803329 7512 128785 880844 118992 550046 992703 232585 500153 102828 601541 624544 439532 970730 464621 796419 469837 873483 8047 161198 894650 70712 727487 58925 521674 97654 138823 653090 302607 742690 368453 436000 88265 764940 15571 232547 463642 736415 522661 894678 258398 885532 511342 10594 708596 564983 300104 460525 299318 213226 591777 443417 918240 595121 555463 614232 944427 896386 517288 750053 844340 190861 812715 983081 452937 92731 495711 329763 246347 709303 799787 555788 82658…
Output: 2123738

Constraints:

2 <= n <= 2560; 0 <= a[i],k <= 1000000.

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