-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
45 lines (37 loc) · 1.02 KB
/
Copy pathtest.py
File metadata and controls
45 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
n = int(input())
tlist = list(map(int,input().split()))
oktlist = list(map(int,input().split()))
idx = 0
ans = []
while idx < len(tlist):
if(oktlist[idx] - tlist[idx] > 0):
pls_time = True
max_time = oktlist[idx] - tlist[idx]
break
elif(tlist[idx] - oktlist[idx] > 0):
pls_time = False
max_time = tlist[idx] - oktlist[idx]
break
else:
idx += 1
continue
ans = []
while idx < len(tlist):
if(oktlist[idx] - tlist[idx] > 0):
if(pls_time):
max_time = max(max_time, oktlist[idx] - tlist[idx])
else:
pls_time = True
ans.append(max_time)
max_time = oktlist[idx] - tlist[idx]
elif(tlist[idx] - oktlist[idx] > 0):
if(not pls_time):
max_time = max(max_time, tlist[idx] - oktlist[idx])
else:
pls_time = False
ans.append(max_time)
max_time = tlist[idx] - oktlist[idx]
idx += 1
if(max_time != 0):
ans.append(max_time)
print(sum(ans))