CT54457

Last windows of Jeweler

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Jeweler the store warden watches over the tulip beds of Bloomhaven's stores of windows. A careful computation stands between order and chaos. 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 <= 2652; -1000000 <= a[i],k <= 1000000.

Example 1:

Input: 1715 1591643 -445326 308105 864222 22863 -741755 -464596 -891115 353210 -376874 385697 -854329 892111 -111869 -955984 601984 -403286 -877457 224327 664013 282946 582709 -356582 326866 -971163 -198434 -640837 731842 -219803 -294832 582518 -763643 -980531 -56463 484412 -66517 -605680 -858069 769193 504196 102372 352522 466694 572842 -331541 -749325 937636 131844 -372123 209074 311917 314332 3417 598233 -824044 2740 833495 922914 516787 -378258 880924 374699 -487341 62579 637588 -624040 -888016 -663384 484598 50548 533843 -684888 279026 -698997 -774996 -553846 -966785 444666 -244583 633598 808224 -98862 64608 206730 -274744 180880 -183439 -768878 -632221 -129949 -542858 945075 -930543 -159246 406346 -247996 -576912 -363146 -314162 445213 -175667 270538 -754895 245619 536082 -401592 -767064 -3…
Output: 1440912

Example 2:

Input: 1038 1836030 179335 248095 -277816 79229 -455739 193788 294774 -972586 -407176 353861 -54805 -40342 344910 624614 1993 519139 -361303 196279 779003 97857 105761 33665 589956 371078 804825 -788239 -14765 192005 -109491 148190 -920392 -98120 163823 862030 235113 -220078 358376 522209 478851 -302670 -534650 504040 708294 76599 482901 -369647 -257694 -142524 410519 -134432 -184237 833997 -867697 616009 780031 -592257 155107 -563076 -231123 -900466 214848 -332120 288522 668113 166583 -487695 -462701 -841095 -941995 -136692 -411624 -959162 -113277 750249 780933 874693 -408973 -890021 109092 -173313 -279857 849510 -970547 813459 565409 123719 -337379 971611 -643178 218547 999916 126922 341476 123638 921373 6510 -934128 729932 -646222 750414 -799732 -986224 -557080 -733952 -915137 -218124 -665348 …
Output: 536875

Example 3:

Input: 950 -377024 -151889 -517600 -80502 557029 -484902 -44308 -802432 775812 545769 37282 -393369 -355679 341206 -114067 633330 904913 -637996 511909 549401 -777226 538198 -940182 2957 555059 -426744 299814 245078 -636600 -336555 -955902 -747860 521165 996241 704349 182312 -57808 -36697 -523119 -181528 -616384 -300696 -205089 580095 105682 -103850 897136 444403 -183551 313849 78212 547079 -909939 -319567 818999 62 929775 676167 676991 -33892 -830315 582139 951447 -233629 340465 371833 -595593 152182 990753 -132556 883385 -195071 -228067 -520121 866821 311011 -127538 545737 -554400 -391935 376889 -135605 -900370 808945 28854 517372 -875794 -980645 -971756 -932308 -750643 -951175 504916 -196542 506502 780844 -590014 -302651 -159080 -93890 438907 -205723 -870755 -414877 -667354 -784837 -588039 672…
Output: 148453

Constraints:

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

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