Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, d = map(int, raw_input().split())
- tsts = []
- for i in xrange(n):
- money, friendship = map(int, raw_input().split())
- for i in xrange(len(tsts)):
- t = tsts[i]
- maxi = t['mmax']
- mini = t['mmin']
- if(money < maxi) and (money > mini):
- n = {'mmax' : money + d if (money + d) < maxi else maxi, 'mmin': money - d if (money - d) > mini else mini, 'f': t['f'] + friendship}
- tsts.append(n)
- tsts.append({'mmax':money + d, 'mmin': money - d, 'f': friendship})
- print(max(tsts, key=lambda t: t['f'])['f'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement