Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, m, t, k = map(int, input().split())
- a = list(map(int, input().split()))
- b = list(map(int, input().split()))
- a.insert(0,0)
- b.insert(0,0)
- if a[-1] < t:
- a.append(t)
- if b[-1] < t:
- b.append(t)
- ans1, ans2 = a[1] , 0
- a_ind, b_ind = 1, 0
- flag = 1
- t_now = a[1]
- while a_ind < n + 1 and b_ind < m + 1 and t_now < t:
- if flag == 0:
- if t_now >= a[a_ind]:
- a_ind += 1
- else:
- flag = 1
- ans1 += a[a_ind] - a[a_ind - 1] - k
- t_now = a[a_ind]
- else:
- if t_now >= b[b_ind]:
- b_ind += 1
- else:
- flag = 0
- ans2 += b[b_ind] - b[b_ind - 1] - k
- t_now = b[b_ind]
- print(ans1, ans2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement