We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents e39af69 + ca132d8 commit 3ce2a61Copy full SHA for 3ce2a61
HackerEarth/Cost-of-Balloons.py
@@ -67,22 +67,21 @@
67
'''
68
69
T = int(input())
70
+
71
while T:
72
purple, green = map(int, input().split())
73
n = int(input())
74
- cost_p1 = cost_g1 = cost_p2 = cost_g2 = 0
75
+ cost_1 = cost_2 = 0
76
77
while n:
78
i, j = map(int, input().split())
79
- cost_p1 += i * purple
80
- cost_g1 += j * green
81
- cost_p2 += j * purple
82
- cost_g2 += i * green
+ cost_1 += i * purple + j * green
+ cost_2 += j * purple + i * green
83
84
n -= 1
85
-
86
- print(min((cost_p1 + cost_g1), (cost_p2 + cost_g2)))
+ print(min(cost_1, cost_2))
87
88
- T -= 1
+ T -= 1
0 commit comments