CT39418

The panels at Scarlet Plain

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the poppy fields of Scarlet Plain with crates of panels, and Quartermaster the cartographer must account for every last one. 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 <= 3932; 1 <= a[i],k <= 1000000000.

Example 1:

Input: 2311 338730397 799818655 530995765 381578390 275321603 125699515 568868801 852811041 188492475 127270694 132798317 270703609 906168911 135381004 828398551 776416291 100990405 610258246 6756230 743124248 107700059 188863720 643302553 450988214 174421179 419297464 271871127 750893259 921966077 692538060 33367881 29319886 129088469 552031916 587878591 304564796 381466747 245291638 350308237 182151016 962960753 62554093 921127074 607027408 75664447 961576434 642833534 329559429 498654388 652133739 543747239 565833082 277639278 497545241 595670994 404229747 973310699 551504294 934602626 27558444 665722772 830050995 774525072 664155574 720583722 300386232 761518509 272504802 890563625 307381859 825463717 858957488 199659925 122405612 521241124 844435787 404281746 165731104 425827111 312006584 15…
Output: 152770

Example 2:

Input: 3764 844297275 228420836 835471394 854108541 810797110 696311185 833523634 500303574 97832981 310938097 178799476 54326130 493990036 490865089 397627282 862972606 824488863 711893415 215884013 281839628 965375401 794563072 897952620 712473288 470065438 899859523 3773473 672527722 404188618 115885985 299002976 975197476 423246266 198319311 691196418 948298163 754579066 266551719 655403678 253612744 195645177 742411830 616377845 743292732 824759384 841664188 425640669 975464639 24574661 172340821 767311286 702323058 2629449 310438842 725143118 580272402 936898880 524881747 997831341 37338450 20131135 348459904 220160769 859682829 212760418 5019259 370066458 169938373 694869743 557779 254038793 948311875 566237146 552333249 834925043 794966224 572605735 241620449 891758581 759492156 855031340…
Output: 2399646

Example 3:

Input: 891 684631430 279022088 302142635 526059409 971406405 655337419 26209824 881979127 945335744 434015933 906638596 136796313 621581270 333036798 715640796 912759845 941190779 495889976 359928977 477363127 954346932 100040800 76711238 552119936 434483503 598809633 923276258 589569425 646212349 216840979 849399968 103241902 138213714 152090101 710763140 594597900 334092895 946653426 6265112 631824660 448954617 58823456 806272869 562848976 379170269 149595109 575545313 273642954 36926342 747257598 974690080 806281243 389411019 894251786 372289643 340721999 18168770 876968742 122240043 577331929 877688561 699553614 838700437 547100390 958971167 153917778 336635234 401209763 675394010 832731006 672406084 766500981 364813869 315585581 109133279 524684954 625972887 519765769 670508821 221411346 786…
Output: 90582

Constraints:

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

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