Hackerearth Pr1.
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
#let's begin
t = int(input('Enter the number of test cases: '))
pr_list = []
for x in range(0, t):
grcost, prcost = input('Enter price of green and purple balloon respectively: ').split()
n = int(input('Enter the number of participants: '))
for y in range(0, n):
points = input("0 or 1 for 1st problem and 2nd problem respectively: ").split()
pr_list.append(points)
points = []
sum1 = 0
sum2 = 0
for z in range(0, n):
sum1 = sum1 + pr_list[z][0]
sum2 = sum2 + pr_list[z][1]
if sum1 > sum2 and grcost > prcost or sum2 > sum1 and grcost < prcost:
print((sum1 * prcost) + (sum2 * grcost))
elif sum1 >= sum2 and grcost <= prcost or sum1 < sum2 and grcost > prcost:
print((sum1 * grcost) + (sum2 * prcost))
Comments
Post a Comment