CT30354

The scrolls at Greystone

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the shale slopes of Greystone with crates of scrolls, and Cleo the archivist 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 <= 1171; -1000000 <= a[i],k <= 1000000000.

Example 1:

Input: 794 1577600804 980747516 735923510 45783731 786966622 437472993 925259556 958325507 771022871 424108139 293887852 105644362 78494452 416580749 557300379 609166324 392165492 490989802 206547004 53099598 817735263 17963286 824058859 407742740 682302224 845052168 295918976 702020966 846773682 237430952 906823640 989289766 306747707 783924763 370963413 979829741 137942358 686204763 976378837 99077275 374345122 338026629 879948287 836225566 549643276 166175835 531354611 570605817 984294669 655157317 337243742 691177775 763108104 277952665 249715643 44280089 755271731 597307079 734343856 559625405 879736888 259394273 46431537 616612887 199304247 516880809 705373586 855387662 362752145 897284496 710416943 538068239 777542424 153188542 591217345 803242705 88599288 684549624 711946281 436956538 438…
Output: 286325

Example 2:

Input: 1014 1455674088 892306456 594984777 721957648 843618991 625555938 850311722 737215581 635199731 7653565 545302715 538759437 394403246 433655425 168573154 443893387 17449051 631416247 39164028 947882523 586931827 878549369 88341380 915330698 532114813 371558835 393984789 969864398 435130555 523478627 975374433 246555022 73681222 140739455 373254390 629603579 844244572 170380117 446567811 136599519 445861679 759763348 818712698 768345170 389087508 574726945 884428576 130373902 893069071 143392826 494974324 656026473 978100520 447135271 95186915 309605898 652580411 407193920 550097093 385543534 523608325 3181570 937926701 477584091 771198517 864798649 304354748 150682484 914263354 82849412 561116842 865526108 307059646 264241432 633578865 187629475 622595863 510554883 74802633 96098850 219792…
Output: 436119

Example 3:

Input: 399 420941542 173135956 440038059 2749568 705698194 797698950 758748384 422174859 276777689 157384118 859135031 520698110 122328567 532680078 900952514 407250814 79256759 697884660 261805655 54753881 398992893 256663918 90984313 409992102 266922822 689807252 252777676 29739234 427548084 706113646 501050591 841495302 315457980 656992903 465387499 455846467 146214608 724813156 317626515 523062543 161470315 720867047 305671914 145809146 420073329 691598159 313024735 5696986 796692722 768884349 901317783 439180170 175975698 503084893 784992045 496823015 433203652 872446516 699115418 659209022 400002759 831677505 34491106 480099526 197592180 255062129 175575122 900142603 506112252 577454971 368952017 851577563 864121140 418465179 586127404 645500118 64738729 436456627 159799164 863180022 797537…
Output: 4584

Constraints:

2 <= n <= 1171; -1000000 <= a[i],k <= 1000000000.

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