CT31294

The Brass panels of Sage

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the fen lights of Will-o-Wisp. Sage 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 <= 3829; 1 <= a[i],k <= 1000000.

Example 1:

Input: 522 984630 886396 198905 924448 176313 787697 200481 46893 147920 993633 558175 968296 830584 927478 849556 351845 597244 847474 653511 35057 587040 102670 863937 78766 883057 576848 966495 84059 868377 660430 240436 155841 731099 422274 737629 421235 96469 447074 748827 438529 533236 574955 777494 888530 568043 226163 903585 421594 388801 498195 895287 830763 323789 742770 992015 415918 941121 280026 577177 916031 946629 682222 908742 497856 328123 642057 417897 9093 154133 162610 797898 83568 999530 941995 382985 681671 697780 188143 743525 523939 69683 429287 934846 836065 701364 950009 296599 922969 914013 229354 612983 151361 109640 498466 88275 916615 326639 227209 934080 872622 825066 393294 269188 553431 591546 814431 227129 23403 841710 881944 338756 464139 751137 895321 750433 12…
Output: 58411

Example 2:

Input: 1141 1780298 190357 574032 898639 631812 329008 246479 690824 399572 180686 263059 400017 962337 149751 420829 54086 442310 17376 514929 799234 649804 388204 677878 917880 431511 92144 538327 136691 16119 18809 448920 390018 721210 716492 911236 826587 171449 30314 103592 462783 215332 691092 433536 380844 287209 284588 79996 863554 426605 768512 930235 211510 459340 195457 334546 508078 430601 221943 148161 967818 189581 310878 134867 274874 164705 67602 170498 50460 375662 913315 677271 940879 26712 230033 731919 939287 138435 474605 885332 600530 847417 688362 136282 351673 777419 720865 461457 522043 909654 80429 774760 75131 41305 582576 936852 124713 432687 950676 325327 616628 67578 151473 878636 108882 605546 452229 55386 665468 285845 756836 13077 476749 266590 541230 863835 45572…
Output: 637043

Example 3:

Input: 1730 197202 10907 483128 825775 202402 364249 251097 890612 175452 810656 489705 940560 199379 68393 99184 576425 843064 216782 546508 465758 976332 85297 633254 84007 212589 957101 833403 900156 342375 764852 785389 636655 566724 862970 573010 517924 306507 960516 215767 41284 147360 913405 458176 253706 325332 544801 733996 399858 382382 720468 269018 751631 874083 56838 247698 228088 230239 706059 59988 100673 44995 406764 746795 522580 309991 830856 98938 230979 929012 165291 978342 150011 676582 597325 245130 776558 892635 539322 265896 85451 251263 674199 65948 696886 782838 148676 513965 551275 501756 50649 918246 365573 865485 962802 947576 41260 573856 55255 906766 885661 88409 160689 658424 662195 540181 25606 65478 111318 45543 491948 997365 304101 819278 415803 217360 713992 75…
Output: 32865

Constraints:

2 <= n <= 3829; 1 <= a[i],k <= 1000000.

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