CT32007

Tanya and the Beryl scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the cotton rows of Whitewick with crates of scrolls, and Tanya the factor 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 <= 1304; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 872 255488884 359057099 216039872 494657591 875959780 383973069 776999 843584356 367301307 126266839 831073355 647406317 114899535 617459816 162119497 915389848 573182801 197038279 556758193 534620158 64561159 132938143 804612141 918221337 183844836 593001685 536295724 674907880 445815160 806036151 663600770 239348703 457508012 427223638 523322491 539999432 840308569 847450995 240077575 274445379 480803150 23925889 572423498 340476762 877399893 879176504 727187716 270231318 960296196 703696035 842022960 446524099 305340324 195152481 81652913 263458350 605301824 718622996 576488371 727668651 548163360 265799111 702100143 516699156 118029194 866283303 124566621 136454803 863195310 320038581 387783774 123417799 607429314 370662339 651474638 782925130 600300575 235985314 790404520 403842307 86…
Output: 10269

Example 2:

Input: 241 1698101885 988739374 305129643 287139243 645192074 824108933 476445828 117982125 489230436 326045439 48186622 614044362 601164013 344668656 426973866 856293603 95036578 371204889 606699680 501619712 937546709 33811124 848360616 919461954 918523820 914890618 952287509 670437375 860173102 552819597 163191062 454539783 600764175 329084774 748709920 939368668 590888609 944688449 396091981 594793500 42649871 192892023 449075505 622810810 652225922 5289064 846289619 829734194 927949946 317800799 802932001 71385770 264556826 457195843 409792054 675690225 566359455 910607199 842472736 197024826 611404531 480987428 795516338 223138798 655259857 541693205 210947352 375995823 722613049 567777343 104496031 916338975 735861917 509777132 748323990 269517951 102749683 277999543 757938393 232230889 93…
Output: 27572

Example 3:

Input: 134 1239130645 24848351 687303933 403445183 323348238 853381546 484886522 25417452 231714035 629773810 811728848 439103441 219213299 653719063 747460086 122512736 221723943 928823100 280477829 805117630 877558210 416492617 981928404 604266656 719109296 226775049 669434628 126319877 924534972 564742479 128314362 690977791 854779072 886707003 574585028 354689358 366803585 84975107 589911546 218782308 821044562 961957148 89890628 647885313 646422529 103538884 908574234 916711898 450679982 874695849 301166716 55402022 842655799 24566015 618844305 787725241 366175396 218936592 795092868 778647474 497293297 37442990 167485534 534091739 860101666 86043163 260310129 691127955 14493428 215080575 236650830 998312789 997714616 343725775 197154171 521399533 183884502 738501650 920570881 83417265 47808…
Output: 6401

Constraints:

2 <= n <= 1304; 0 <= a[i],k <= 1000000000.

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