CT33019

Brevin and the Smoky stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Brevin the store warden watches over the mulberry rows of Silkmead's stores of stretches. A careful computation stands between order and chaos. 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 <= 2796; 0 <= a[i],k <= 1000000000.

Example 1:

Input: 1585 1974985943 306417931 449650347 406563807 921852153 485510762 937369514 957910036 157276594 333124343 235273493 422647526 853311377 411410241 969836184 457653410 98214367 908176897 347400836 535805000 462680253 845606301 130265388 379899756 684267514 661456099 649414438 890345297 248265925 858678685 389287103 155445809 315162379 546583363 256111828 110839802 694188311 308863577 903561726 222507400 550520023 682166032 877753849 242854366 926578952 340999685 683816234 231809639 196581395 136403460 986499755 156658268 84572570 618253124 100718456 135114280 894760632 990513025 890956769 619477104 417697102 880308225 301633498 919557508 895453553 619041522 647441775 20406794 472484261 870700405 330426819 966969671 945982168 825303193 359094654 34059592 709439224 615804731 71533618 482279810…
Output: 1255075

Example 2:

Input: 1304 1441891105 500763383 155739558 408922540 59688551 358222825 740848158 143482079 425964659 704126342 562542619 538429907 19362438 798255720 663835191 688221184 270170785 960980393 980401944 280404975 595644653 430246062 556434414 90137672 552812230 881122040 598805414 651286222 256736250 569752334 864436890 314599662 49074754 905800962 566422535 611404106 795181972 684801697 947762541 846140168 898211151 816023875 753998755 96567857 710114998 390077379 42295732 331647300 439301407 58377237 614731840 12355882 650750195 356714968 573328529 431076601 817328589 289453231 935895850 861435781 80619779 716801182 697627703 501997241 266027885 157139036 952427279 336896749 243109534 324882642 200752971 247679254 943682023 75082455 735249181 730715813 742424048 645607239 275038604 748026837 3408…
Output: 707279

Example 3:

Input: 2484 929399327 859021317 214730040 56404822 606057146 756673159 511668951 983514435 475932339 690079951 415715369 422898167 901072822 139676054 218407468 655833241 373109781 525371820 933002193 544880917 548523925 960296029 951820933 689104861 965175275 473949984 959180450 487835606 739105054 660645999 383535190 663860047 934582461 540289433 907055395 771321707 604246135 289450154 146718165 22279794 946283809 700271308 717249652 531838604 312678339 22741657 328237685 679196434 402762419 56245595 72437261 882350582 349471922 323804014 685845766 157686893 909590559 232125469 846023934 225700280 658051290 125837961 757760065 379798721 963856770 162038403 79006898 444629942 483563885 69560882 316490671 190054506 64945541 664899413 482077385 705524316 544300454 810320105 745853457 515956610 268…
Output: 1353839

Constraints:

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

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