CT41738

Harish and the Peculiar windows

MediumL5 · Recursion RenegadeAcceptance: 0.0%XP: 60

Caravans arrive at the smokehouses of Brineport with crates of windows, and Harish the registry keeper must account for every last one. 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 <= 1617; -1000000 <= a[i],k <= 1000.

Example 1:

Input: 993 -155022 -726293 -91301 -368484 -255259 -608768 -166159 -306546 -889691 -611754 -256252 -851458 -333812 -735241 -234646 -540489 -377920 -312035 -507730 -662386 -553342 -273866 -785354 -682691 -902532 -445353 -511299 -775064 -787957 -274902 -251645 -536684 -132038 -731057 -299695 -835690 -153664 -609662 -872670 -595529 -190569 -304442 -42106 -888267 -619381 -912519 -781348 -514362 -772392 -656469 -530251 -261376 -749273 -169708 -103930 -29323 -224522 -286045 -152995 -643237 -912497 -702083 -515926 -662637 -414569 -486628 -626920 -191100 -184165 -651096 -467930 -511806 -982678 -659435 -385482 -334784 -38614 -979208 -697950 -140374 -934199 -142171 -235916 -919189 -505806 -452339 -215064 -940350 -303878 -293753 -329646 -871829 -77764 -33078 -191859 -131241 -198972 -369578 -166537 -758908 -2…
Output: 486843

Example 2:

Input: 1521 -790031 -962006 -374365 -455112 -970946 -211896 -732530 -292993 -26337 -322966 -703032 -141275 -551973 -763571 -975349 -872862 -925084 -814147 -977437 -682301 -679899 -226611 -266080 -273771 -924720 -517198 -846307 -712174 -249228 -821737 -825785 -73953 -564195 -518226 -291811 -122022 -348724 -921144 -378288 -787831 -555032 -145628 -642597 -163070 -900731 -336915 -350921 -285917 -438637 -787550 -125299 -342013 -869524 -712526 -848959 -566878 -886435 -684081 -216399 -413134 -610082 -292059 -507798 -64644 -722778 -179920 -7427 -156537 -260899 -674163 -132828 -35562 -607108 -276913 -862705 -344811 -535187 -430807 -348630 -123420 -569270 -163763 -19713 -751496 -628500 -265335 -422966 -114708 -442322 -797103 -167552 -437224 -635431 -297567 -781945 -530039 -333914 -165453 -180027 -892361 -4…
Output: 787087

Example 3:

Input: 20 -528243 -838272 -397988 -162503 -235452 -544219 -617135 -563245 -762408 -990320 -160459 -296121 -329104 -137513 -426053 -494943 -673400 -57721 -689038 -150387 -639007
Output: 163

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Harish and the Peculiar windows - MEDIUM Coding Problem | CodeTikki