码迷,mamicode.com
首页 > 编程语言 > 详细

CCF买菜(python)

时间:2020-01-08 00:27:03      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:split()   int   max   pytho   inpu   pre   input   end   ==   

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)

标签:split()   int   max   pytho   inpu   pre   input   end   ==   

原文地址:https://www.cnblogs.com/walkwaters/p/12164293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!