CT56174

Dante Counts the stretches

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Deep in the cork grove of Barkhaven, Dante studies rows of stretches entries. One clean number will settle the guild's oldest argument. 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 <= 2096; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 2016 745699 344126 -705382 -387619 794929 -444488 829973 -942776 -959186 272947 -882978 -329014 -400071 -233036 286383 425102 -340568 -723826 920179 -424730 663032 -948263 469321 938441 165149 -325092 -448136 -70632 -804549 127048 868834 -443894 90454 -919430 760089 437719 119144 746061 -484902 575571 476554 -79161 925193 274668 -817104 -152361 611886 641931 802901 -460332 -744047 -297830 -710079 -420279 333865 -764882 -535446 -93375 655123 -87075 358154 211931 888869 142242 -466589 819613 -310913 758321 -344775 560073 -77871 -886497 530962 769182 -692797 915527 -572731 -385479 999554 -308897 596656 822985 161048 -150864 629961 613472 379667 -156607 -95968 678177 -387766 671793 -317878 197607 -455779 836765 159637 -540085 -833425 941822 -283904 68673 870473 -157976 997278 551850 537875 -67…
Output: 1610262

Example 2:

Input: 1102 1390981 341005 229401 549682 -596302 397172 -72724 699120 508318 -794137 -382424 -615050 -749404 -53959 -394170 -409451 -543552 153777 879542 727253 -231458 503570 288701 603968 -705369 470594 -188803 -739200 -295472 397709 110703 244870 -60526 956276 -783999 -177801 -452106 -691791 -925888 160026 -119996 -655126 397466 -192533 -432664 -31504 -117119 858956 503911 -543586 625909 946249 -110303 -565785 -99504 -471713 -243018 -225772 589050 788256 -855054 -881887 719292 205168 515560 93124 -244747 233450 -756811 273686 666942 584886 -840461 22414 -144963 338371 579491 -695548 -143976 -371613 -777490 -876677 -567047 820074 -516861 14100 -54362 516484 -813222 806645 -12817 392350 551850 -137916 199954 -971772 40668 283438 290171 613571 -167225 -680623 -365580 -950699 386191 -484802 -94748…
Output: 576469

Example 3:

Input: 1425 1000436 -363776 -397915 600639 -149895 552557 -271479 938727 -910856 -836688 610176 -676821 868120 -646807 -205080 579910 -417920 706393 -40549 285326 -369743 -920557 -895439 742162 793885 -919944 -745586 275675 -445 339886 -608687 559686 -624907 498910 153253 301528 977031 -855062 472104 -875077 -877321 91311 -751953 543805 -631658 751803 -263914 292753 -541557 219384 -221004 -727599 -461458 878196 -69725 -426244 -122039 524876 -512136 967505 47304 34501 -936146 998586 462028 611803 -11007 -285014 -66902 933051 -455019 733738 366392 840325 586964 -784083 -123971 857584 -837589 870231 -278639 -929729 72255 890081 -323283 365218 -159142 785987 -512177 -461875 -623225 -660866 664660 -800365 761625 191723 -201425 744940 -472866 884036 848612 136461 626392 -81065 694587 -144660 648902 -65…
Output: 877167

Constraints:

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

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