CT29628

Jace and the Pearl panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the desert outpost of Sandspire. Jace spreads the panels records across the table and picks up a sharp pencil. 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 <= 1239; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1001 1767702998 258491604 538057148 852274642 715593662 986302742 301644740 545759369 537935120 744173175 139984547 897734782 548012203 877400562 949129108 326710757 631649522 147268090 941380148 532731035 152162871 590832832 772657376 114044790 259842691 191656884 383941107 73187316 481526371 486954604 29000429 558245415 19347072 834844613 710261370 444936010 979229749 864153190 49934514 226529035 212939115 985554470 251597930 355507514 915813816 40628246 707494731 448969614 965232111 591827129 371798367 716691927 737744716 5017607 924476109 73119810 689670174 118027769 794357702 151841470 577749895 410473725 277294126 409407312 802782067 20070342 384721517 65143661 836055505 631239383 396744820 160565559 768329244 545822754 699255118 927686993 427725481 975775332 701793612 241432675 6047…
Output: 490186

Example 2:

Input: 977 754941540 150094462 883052462 43722981 685145763 181872576 977269549 489913938 536048064 225653510 274690427 72092165 512754720 53818093 642420733 672315666 181819322 501807309 710303842 295797835 404396979 390699028 60286241 168525609 198926632 896019537 488612446 402395594 12506458 356315016 547619647 685439560 715576174 113370806 412427515 2735365 452069547 752576086 71254858 894938317 459400307 460059081 270223525 254098859 470398994 985378271 207743512 798096852 966150066 251593076 166560103 668956601 5974210 730396538 59858143 303266172 232070200 814746814 176251895 275121194 264510899 617759603 739706522 919212991 263194644 138209415 113164180 691229068 434378563 838514245 963542646 988725327 309975946 133083749 968712431 543439658 354889860 839530377 904884157 818512685 2396349…
Output: 134632

Example 3:

Input: 868 706930024 422948321 684055213 876435436 84536883 767586587 426088151 672206636 316915379 746045050 875349455 407921044 755528147 884314507 559303554 387145255 465925881 419320156 3009413 785703327 688560300 8003478 197352214 898896448 510843051 335911986 733871953 115574851 69642851 736221219 807455587 374673802 88632437 20502794 227713343 731382646 565253476 891349575 656833509 845488334 164024175 84190732 385692854 480998276 427185050 503986148 843128710 232185527 328051403 102017499 127677284 401172632 869873065 384074103 240238803 650553870 857798178 131776644 947507403 434821079 868767597 173082117 182439584 677052668 6186693 59718253 69683431 649307330 916322853 951476505 452311289 231002834 973722497 409182473 962288872 106257864 738543878 832802848 449331835 411928213 656175850…
Output: 99145

Constraints:

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

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