CT34019

Chetan's Solar ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The chronicler Chetan has been asked to file the annual report. On the desk lies a long table of ribbons readings. 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 <= 2172; 1 <= a[i],k <= 1000000.

Example 1:

Input: 1569 748726 806535 375191 837468 574215 798058 593884 787186 46760 133889 657941 431716 68419 831872 200182 470737 443617 825211 537420 278329 603563 458949 453717 656983 91697 982609 633973 514773 190054 483044 515728 416682 416803 675344 364864 786767 29133 160291 291301 220484 735816 673250 887659 194977 956324 82704 121244 101300 784635 705988 72162 587007 705292 566500 352894 127904 843515 41734 132271 290956 327318 109482 428920 643300 661735 482761 674613 759263 477558 159813 123840 83247 688972 336102 247576 976749 491164 192337 676095 837641 543659 543355 936915 479591 219646 409693 702457 308836 174858 783399 596638 775707 30245 921684 900262 78742 104277 587941 259946 692132 919253 354760 88121 335300 984993 10891 144694 614565 805293 876184 562000 207616 894005 928495 593007 12…
Output: 363512

Example 2:

Input: 851 1838294 898536 121301 689681 745734 171506 765287 94999 618730 521358 934779 561936 62306 842786 993587 474645 432577 748219 668901 642822 141184 668147 554981 409412 97344 474848 519890 728033 189022 220856 420450 899603 510439 826800 878033 909948 112725 271165 798537 468678 493102 149811 260864 855906 70192 181038 992254 856905 993060 374211 641840 316369 473115 924637 157323 324863 582547 49244 779718 918411 986817 271591 787857 507202 818147 551713 110311 927525 440190 33833 460787 885870 370241 773453 423293 983680 930832 819991 702946 238155 365159 438721 418642 523845 401355 809574 72761 299460 219062 323354 961981 515534 798355 201820 671021 817809 967080 22616 115577 817203 474638 93174 996752 21114 665057 725313 441249 885577 733687 132943 713976 372982 576257 370980 905206 …
Output: 357166

Example 3:

Input: 1792 142286 411741 37175 118744 159409 544607 319463 886025 803928 69060 519504 704135 268755 666918 551068 775535 345634 292912 681973 233196 537027 858984 889657 399278 255052 984691 55758 824416 369852 900384 15781 912116 367789 423059 75059 681795 21536 615140 185885 852312 439159 833613 28837 986694 797219 211141 488338 116805 861296 140732 516138 680394 505629 187086 574992 20088 68828 668729 242177 360528 688301 987983 946668 298468 908956 792646 334539 907722 754920 207861 554843 565818 190372 80403 977399 652947 582461 699094 190141 960403 722156 966616 864994 889107 510482 497014 523241 301722 683400 416249 642804 401958 798043 951793 24869 190960 925092 147012 385445 572290 204703 530867 260370 907438 806273 191414 342407 65490 571547 911307 827103 812815 165340 993503 263512 11…
Output: 16115

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chetan's Solar ribbons - MEDIUM Coding Problem | CodeTikki