Editorial for Banana 1


Author:kahootist

Code 1
# Import the math module since we'll be using it for rounding numbers up.
import math

# Get the first line of input and store it
input_line = input()

# Split the line into two parts 
split_input = input_line.split()

# Retrieve the two integer inputs n and c,
# by getting the first and second items in split_input,
# then converting them into integers.
number_of_monkeys = int(split_input[0])
cost_per_pack_of_ten = int(split_input[1])

# We want to keep track of how many bananas the monkeys are demanding.
bananas_needed = 0

# Now, for each of the next n lines,
# there is an amount of bananas that we must add to the required total.
for _ in range(number_of_monkeys):
    bananas_needed += int(input())

# Since we can only buy bananas in packs of 10,
# we must round up the number of bananas we need to the nearest multiple of 10.
number_of_packs = math.ceil(bananas_needed / 10)

# Each pack costs c dollars,
# so the total cost is the number of packs times cost_per_pack_of_ten.
final_cost = cost_per_pack_of_ten * number_of_packs

# Print the final answer!
print(final_cost)

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.