CCF买菜(python),,n = int(in


n = int(input())
H = []
H1 = []
W = []
W1 = []
CountTime = 0
for i in range(n):
list_H = input().split()
H.append(int(list_H[0]))
H1.append(int(list_H[1]))
for i in range(n):
list_W = input().split()
W.append(int(list_W[0]))
W1.append(int(list_W[1]))
max_H = max(H1)
max_W = max(W1)
maxTime = 0
if max_H >= max_W:
maxTime = max_W
else:
maxTime = max_H
Hx = 0
Wx = 0
for i in range(1,maxTime):
H_flag = 0
W_flag = 0
if i >= H[Hx] and i < H1[Hx]:
H_flag = 1
elif i >= H1[Hx]: Hx += 1
if i >= W[Wx] and i < W1[Wx]:
W_flag = 1
elif i >= W1[Wx] : Wx += 1
if H_flag == 1 and W_flag == 1:
CountTime += 1
print(CountTime)

CCF买菜(python)

评论关闭