CT33349

The panels at Bramblecourt

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Tina runs the stall at the thorn maze of Bramblecourt. Today the books show a list of panels, and the numbers must be worked out before sundown. 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 <= 3039; 0 <= a[i],k <= 1000000.

Example 1:

Input: 2702 148709 849320 358780 868872 89658 667772 85475 269556 566524 735459 720614 684890 889764 404996 313177 657239 869672 776931 974131 522391 183074 423106 682401 784483 658826 931305 636336 794426 791574 288149 269735 983587 40490 474527 739156 191384 870800 569994 913527 76848 476518 822893 768364 700911 365849 912605 880636 437103 328017 841782 200140 399732 202314 276641 450432 468728 269530 217979 271198 258471 406334 129370 516703 677111 417594 193425 892305 476028 413614 918482 486978 846042 988073 934547 238517 646074 850646 183339 639538 738361 870859 75245 795536 273088 346304 548256 582979 423800 312318 41182 369773 741169 201300 350304 460495 447244 277606 228825 431336 490492 488577 19780 819325 425206 698818 7392 941764 36358 782294 386317 171218 886259 537763 307526 179267 …
Output: 38508

Example 2:

Input: 1313 381668 67959 482810 478022 408805 159255 801184 456334 480767 29437 769516 416970 673300 204969 740141 136674 439181 686963 649905 631166 806534 246314 897945 172561 124496 191508 397701 874514 486863 26839 266824 629064 59648 886062 473337 799198 115308 793804 734577 636804 737036 258318 624862 516071 366502 628707 278280 274248 339519 518151 729063 968542 273432 192420 938101 248273 946030 675770 871914 281610 471886 422800 965293 751326 294468 191035 522969 455857 129788 877293 457171 851487 847004 801633 972931 187269 889521 444851 495914 58290 98289 776005 555957 683377 421693 779923 701418 191628 902571 775194 11912 577857 818202 662006 886818 374088 544300 533143 743549 876089 236490 287653 951101 511003 482386 227016 696001 454310 18764 656055 298202 584976 842474 112184 77283…
Output: 59195

Example 3:

Input: 2050 791554 326637 686635 192018 717161 128316 83769 794917 254763 917830 230304 951352 309287 360617 143700 975427 185651 846976 80232 629058 854569 157344 489030 105083 810909 363752 122810 338273 99168 76871 725738 852302 727636 667361 744061 635002 235760 23042 216832 443542 665135 479657 715592 753225 959893 100764 688228 29120 536688 105369 862525 341422 563785 962412 957968 2148 257586 194090 519958 776230 229360 848428 172908 427790 346883 269006 915259 106009 768237 235796 46706 742235 79761 485499 983681 769896 230979 414371 883867 687199 188907 638240 913762 25888 445370 393019 228621 211824 961469 60448 883817 891986 809125 780461 486714 84007 653348 58478 255703 440628 590002 895284 443612 485058 202391 748102 425941 225010 985130 879729 402387 463728 968792 886363 750386 4171…
Output: 681634

Constraints:

2 <= n <= 3039; 0 <= a[i],k <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The panels at Bramblecourt - MEDIUM Coding Problem | CodeTikki