#C11694. Calculating Total Donations

    ID: 41038 Type: Default 1000ms 256MiB

Calculating Total Donations

Calculating Total Donations

You are given multiple test cases involving donation events. Each test case provides three donation rates: \(A\), \(B\), and \(C\). Each participant donates based on the distance they have covered according to the following rules:

  • If the distance is less than 5, the donation is \(A\).
  • If the distance is between 5 and 15 (inclusive), the donation is \(B\).
  • If the distance is greater than 15, the donation is \(C\).

Your task is to compute and output the total donation amount for each test case.

inputFormat

The input is read from standard input and follows the format below:

  • The first line contains a single integer \(T\) representing the number of test cases.
  • For each test case, there are three lines:
    • The first line contains three space-separated integers \(A\), \(B\), and \(C\).
    • The second line contains an integer \(N\), the number of participants.
    • The third line contains \(N\) space-separated integers indicating the distances covered by each participant.

outputFormat

For each test case, output a single line with the total donation amount computed using the rules described above.

## sample
2
50 75 100
5
3 5 10 18 20
20 30 50
4
4 12 25 8
400

130

</p>