Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. n, m, t, k = map(int, input().split())
  2. a = list(map(int, input().split()))
  3. b = list(map(int, input().split()))
  4. a.insert(0,0)
  5. b.insert(0,0)
  6. if a[-1] < t:
  7.     a.append(t)
  8. if b[-1] < t:
  9.     b.append(t)
  10.  
  11. ans1, ans2 = a[1] , 0
  12. a_ind, b_ind = 1, 0
  13. flag = 1
  14. t_now = a[1]
  15. while a_ind < n + 1 and b_ind < m + 1 and t_now < t:
  16.     if flag == 0:
  17.         if t_now >= a[a_ind]:
  18.             a_ind += 1
  19.         else:
  20.             flag = 1
  21.             ans1 += a[a_ind] - a[a_ind - 1] - k
  22.             t_now = a[a_ind]
  23.     else:
  24.         if t_now >= b[b_ind]:
  25.             b_ind += 1
  26.         else:
  27.             flag = 0
  28.             ans2 += b[b_ind] - b[b_ind - 1] - k
  29.             t_now = b[b_ind]
  30.  
  31. print(ans1, ans2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement