Editorial for Banana 1


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: kahootist

# 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)

Comments

There are no comments at the moment.