Skip to content

Commit 5c567ef

Browse files
authored
Update minimize-the-total-price-of-the-trips.py
1 parent a69f6d4 commit 5c567ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/minimize-the-total-price-of-the-trips.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ def dfs(u, p, target):
9494
return False
9595

9696
def dfs2(u, p):
97-
full = full_or_half = 0
97+
full, half = price[u]*lookup[u], price[u]//2*lookup[u]
9898
for v in adj[u]:
9999
if v == p:
100100
continue
101101
f, h = dfs2(v, u)
102-
full += f
103-
full_or_half += min(f, h)
104-
return price[u]*lookup[u]+full_or_half, price[u]//2*lookup[u]+full
102+
full += min(f, h)
103+
half += f
104+
return full, half
105105

106106
adj = [[] for _ in xrange(n)]
107107
for u, v in edges:

0 commit comments

Comments
 (0)