Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Last active January 1, 2016 17:29
Show Gist options
  • Save cocodrips/8177945 to your computer and use it in GitHub Desktop.
Save cocodrips/8177945 to your computer and use it in GitHub Desktop.
noda
import itertools
import bisect
def solve(items, camps):
combi = itertools.combinations(items, 2)
sums = [a+b for a, b in combi]
sums.sort()
for camp in camps:
i = bisect.bisect_right(sums, camp)
if i == 0:
print 0
else:
print sums[i-1]
if __name__ == "__main__":
n, m = map(int, raw_input().split())
items = []
camps = []
for i in xrange(n):
items.append(int(raw_input()))
for i in xrange(m):
camps.append(int(raw_input()))
solve(items, camps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment