Allowance (3)

You have saved n euros. Additionally, every Monday of the forthcoming
weeks you will be given a weekly allowance. On odd weeks, you get a_(o)
euros, while on even weeks you will receive a_(e) euros. On the i-th
week, your amount of expenses sums up to d_(i) euros. The first week is
the week i = 1 and, therefore, it is an odd week.

Write a program that computes the balance at the end of each week.

Input

The input consists of three natural numbers, a_(o) ≥ 0, a_(e) ≥ 0 and
n ≥ 0. Representing the allowance on odd weeks, the allowance on even
weeks and the initial savings, respectively.

Following, there is a non-empty sequence of natural numbers where each
element d_(i) ≥ 0. Each element d_(i) represents the expenses of the
i-th week.

Output

The output is a sequence of integers. Each element of this sequence
b_(i) indicates the balance at the end of the i-th week, once the
corresponding expenses are payed.

Follow the format specified in the examples. Your code should follow the
rules of style and contain the comments that you deem appropriate.  

Problem information

Author: Unknown
Translator: Maria Serna

Generation: 2026-01-25T22:46:30.430Z

© Jutge.org, 2006–2026.
https://jutge.org
