Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('26.txt', 'r') as f:
- data = [[int(q.strip()) for q in i.split()]for i in f.read().strip().split('\n')]
- first, second = [i[0] for i in data], [i[1] for i in data]
- sec = True
- val = 7300
- S = 0
- cor = [7300]
- def find_in_f(v):
- for idx, val in enumerate(first):
- if v - val >= 5:
- return idx, val
- return None, None
- def find_in_s(v):
- for idx, val in enumerate(second):
- if v - val >= 5:
- return idx, val
- return None, None
- while True:
- if sec:
- idx, v = find_in_f(val)
- if not v:
- break
- val = v
- sec = False
- S += v
- cor.append(v)
- else:
- idx, v = find_in_s(val)
- if not v:
- break
- val = v
- sec = True
- S += v
- cor.append(v)
- print(cor)
- print(sum(cor), len(cor))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement