CT54829

Shepherd's windows Frugal Pairs

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

The auditor Shepherd has been asked to secure the caravan contract. On the desk lies a long table of windows 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 <= 1735; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 478 -454664 -416981 -782030 -354772 -87663 -200126 -574270 -848451 -103428 -335517 -586129 -746204 -459559 -789029 -763585 -735707 -347524 -96826 -974777 -128451 -8874 -926811 -629890 -631775 -254814 -335714 -899970 -175296 -724838 -245405 -447788 -907006 -437566 -480745 -381491 -342045 -785018 -320883 -60856 -789140 -484660 -20091 -229687 -276327 -442406 -330970 -927665 -395916 -640901 -851585 -31638 -743422 -432048 -706808 -792717 -587262 -915091 -527394 -314244 -256597 -665682 -3198 -30765 -760611 -170550 -934511 -97798 -282623 -671494 -755333 -825018 -710313 -206176 -999170 -936816 -365148 -235334 -805805 -68975 -180878 -749168 -690907 -981711 -143934 -501611 -73907 -423205 -572895 -320516 -942676 -269820 -492564 -841996 -396490 -469457 -157227 -824355 -577941 -379762 -491889 -634014 -…
Output: 102600

Example 2:

Input: 491 -489694 -138374 -267441 -673151 -312271 -807569 -400537 -70993 -943377 -430011 -545809 -369474 -619405 -541944 -276278 -808097 -825431 -797889 -854096 -363793 -422611 -268310 -542351 -706708 -824150 -821963 -750868 -451622 -196810 -674413 -72539 -210298 -267422 -791124 -569725 -6467 -138529 -105737 -625393 -510895 -136748 -297620 -273216 -137946 -562103 -204756 -37048 -960826 -566907 -546301 -936005 -793939 -952582 -765621 -964557 -894039 -548349 -619229 -662254 -445064 -592655 -794524 -14515 -844091 -401653 -737463 -735991 -931840 -536928 -244452 -714821 -92323 -453390 -574740 -361533 -383809 -468773 -525565 -90435 -477647 -32533 -350857 -471081 -324539 -415857 -562580 -893320 -916064 -698471 -364360 -368286 -530167 -353056 -551005 -797301 -168380 -73377 -378032 -977982 -514720 -16456…
Output: 103885

Example 3:

Input: 501 -757444 -791897 -20354 -311680 -511183 -722268 -309519 -19337 -13539 -364405 -986599 -697637 -83276 -27091 -159704 -922604 -692189 -818592 -70676 -236811 -589533 -42052 -178722 -202273 -807211 -65905 -30337 -491811 -593748 -381376 -807054 -753378 -289932 -929096 -594877 -637354 -921 -487293 -782257 -450325 -408524 -130299 -927498 -830048 -977333 -74011 -343855 -823549 -596741 -618905 -574080 -443881 -678421 -88830 -220686 -747336 -56299 -295337 -619938 -635342 -569200 -305057 -664821 -897126 -795549 -884351 -810687 -85596 -916641 -212247 -502584 -221983 -116556 -170901 -681737 -133747 -616368 -921081 -145313 -253131 -445723 -17664 -512293 -273027 -824174 -430823 -33531 -380940 -382319 -83809 -717198 -31252 -84067 -176028 -285218 -880599 -94814 -377341 -862635 -847494 -199390 -408688 -2…
Output: 83330

Constraints:

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

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