CT30398

The stretches at Rye Hollow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the gristmill of Rye Hollow close for winter, Mira must finish the stretches ledger - one figure at a time. 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 <= 1625; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 971 755853 -708812 110276 -748301 976859 -209847 -54228 260714 -704621 887658 -600144 -301371 214154 -635026 69786 -376880 569534 -407810 -528022 169495 -68561 356085 374074 190457 573200 -970953 877487 -667990 -678752 242156 434442 -329178 -85455 -741253 653772 -238843 603715 -949751 -803157 -496998 -377275 373373 -406179 976396 -298211 -952760 932469 42427 329087 1234 -623469 662722 60718 297513 -878960 699061 308555 601422 -208819 630281 311514 -919750 257736 807566 -644895 105000 658530 -846358 875727 -522027 -820135 966959 175106 -948016 -295362 -181423 470764 -501903 -986705 -72273 719318 394748 49439 -902089 -561670 562217 -360672 903871 77152 87125 -460772 493248 -232831 -274843 826235 360754 559649 576644 -216264 -733572 826917 -698865 -963650 -484948 -969118 451887 497233 601196 …
Output: 381323

Example 2:

Input: 1337 1021382 -63075 -59294 560940 420197 -557981 -387842 813250 353539 925588 831057 103934 68240 -253677 236497 -577736 -31999 490662 998030 -809610 -155316 792673 -600448 -673760 -74332 29061 271657 110861 -32082 -421703 -296103 401994 -415696 -552953 136694 -797335 -807741 894983 683540 -706166 229021 -79199 610167 -638818 648038 918369 -492619 -700711 91002 -432791 149647 86585 -789771 322752 -627276 40417 992884 120829 -925882 -396494 844321 658834 815843 87269 952257 -627931 -764724 915724 839862 920910 -29533 -85902 -937632 -405191 -257415 -132396 -465186 248672 -301482 130814 -284465 -647966 497184 265696 505449 -242273 591213 452020 -316838 278860 113619 -891385 351958 -757397 303921 -817043 -461851 151668 -375713 366108 -378496 -639681 794313 230439 458261 574389 58162 22317 7222…
Output: 768515

Example 3:

Input: 974 1677416 112686 -94618 -727113 9170 578933 -960196 739632 -374634 -285012 -995776 37559 -939586 356993 -842780 -797365 -17140 807718 -882129 199687 907418 -57428 -382201 -693247 962953 -973467 766310 562690 -128043 -30842 142496 -771726 378384 757707 -308091 735439 243332 635662 83145 682924 885506 -611570 -268889 540540 868996 -549652 577268 338314 963094 -78965 -499939 -572054 193932 107942 -172305 759291 -823192 121238 549548 677159 -769726 120346 -270752 525930 -6714 -872190 -272534 -427455 -704986 978054 -135442 238068 -390361 -907518 253884 41503 -165748 396455 564200 665285 581187 -102071 33563 30404 422542 -715341 695109 -293892 625820 -914042 983037 -5670 151968 739103 -235298 146137 -123071 501732 -7857 624465 793601 942962 -81736 -770606 633823 62425 -354449 -631618 -344045 9…
Output: 468361

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The stretches at Rye Hollow - MEDIUM Coding Problem | CodeTikki