AIOC Banner

Problem: Wetlands

Want to try solving this problem? You can submit your code online if you log in or register.


Input File: wetin.txt
Output File: wetout.txt
Time Limit: 1 second

The Friends of Wetlands have dammed a creek to provide water for the nearby wetlands. During each month some rainwater flows into the dam, and then at the end of each month precisely 10 megalitres of water are released into the wetlands. If the dam contains less than 10 megalitres at the end of the month, the entire contents of the dam are released.

The local firefighters view the dam as a potential source of water to fight bushfires, and would like to know how much water there is likely to be in the dam in the height of the bushfire season in eight months' time. Your task is to use predicted rainfall figures to answer this question.

For example, suppose the predicted amounts of rainwater flowing into the dam for each of the eight months are 12, 9, 10, 7, 10, 13, 9 and 15 megalitres respectively. Assuming these figures are correct, after the first month the dam fills with 12 megalitres, and then 10 megalitres are taken (leaving 2). After the second month the dam fills to 2+9=11 megalitres, which is then reduced to 1. After the third month the dam fills to 11 megalitres and is again reduced to 1.

The fourth month is more interesting--here the dam only fills to 1+7=8 megalitres. Since the usual 10 megalitres cannot be taken, the dam is emptied completely. After the fifth month it fills to 10 and is again emptied, then it fills to 13 and reduces to 3, then fills to 12 and reduces to 2, and finally after the eighth month it fills to 17 and reduces to 7. Therefore your final answer for the firefighters is 7 megalitres.


There will be precisely eight lines of input. These lines contain the amount of rainwater arriving in the dam each month, in order from the first month to the last (measured in megalitres). Each of these lines will contain a single integer between 0 and 100 inclusive.


Your output file should contain a single integer, giving the amount of water left in the dam after the eight months are over (again measured in megalitres).

Sample Input


Sample Output



The score for each input scenario will be 100% if the correct answer is written to the output file, and 0% otherwise.


Privacy statement
© Australian Mathematics Trust 2001-2023

Page generated:  3 June 2023,  1:59pm AEST