Skip to content

Commit 3ce2a61

Browse files
2 parents e39af69 + ca132d8 commit 3ce2a61

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

HackerEarth/Cost-of-Balloons.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,21 @@
6767
'''
6868

6969
T = int(input())
70+
7071
while T:
7172
purple, green = map(int, input().split())
7273
n = int(input())
7374

74-
cost_p1 = cost_g1 = cost_p2 = cost_g2 = 0
75+
cost_1 = cost_2 = 0
7576

7677
while n:
7778
i, j = map(int, input().split())
7879

79-
cost_p1 += i * purple
80-
cost_g1 += j * green
81-
cost_p2 += j * purple
82-
cost_g2 += i * green
80+
cost_1 += i * purple + j * green
81+
cost_2 += j * purple + i * green
8382

8483
n -= 1
85-
86-
print(min((cost_p1 + cost_g1), (cost_p2 + cost_g2)))
84+
85+
print(min(cost_1, cost_2))
8786

88-
T -= 1
87+
T -= 1

0 commit comments

Comments
 (0)