AtCoder Beginners Contest 080 [A to C]

Tasks

 

A. Parking … Simple comparison with if

n, a, b = list(map(int, input().split()))

print(a*n if b > a*n else b)

 

B. Harshard Number … Given one number, and judge if the number is Harshard Number. use modulus.

x = input()

fx = sum([int(num) for num in x])

print("Yes" if int(x)%fx == 0 else "No")

 

C. Shopping Street … Given one number, and two lists. And calculate the highest profit we can earn.

n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))

result = -float("inf")

# opening schedule for my shop.
# start from 1(only open Mon.AM) to 1023(open all day)
for b in range(1, 1<<10):

    profit = 0
    # compare with other shops
    for i in range(n):

        common_opening = 0
        # compare time
        for j in range(10):

            if 1&(b>>j) and f[i][j] == 1:

                common_opening += 1
        profit += p[i][common_opening]

    result = max(result, profit)

print(result)