Colorful Flowers Count: In a garden, there are N flower plants in a row. There are three types of plants which are given below.
Type 1: It gives only a red flower every day.
Type 2: It gives only a green flower every 2 days.
Type 3: It gives only a blue flower every 3 days.
Initially, there are no flowers in the N plants. The program must accept N characters denoting the colors of the N plants and N integers denoting the maximum number of flowers that the plants can give. The program must print the total number of flowers in each color that the gardener can get in T days. The value of T is also passed as the input.
Boundary Condition(s):
1 <= N <= 100
1 <= Each integer value <= 1000
2 <= T <= 1000
Input Format:
The first line contains N.
The second line contains N characters separated by a space.
The third line contains N integer values separated by a space.
The fourth line contains T.
Output Format:
The first line contains the total number of flowers in each color that the gardener can get in T days.
Example Input/Output 1:
Input:
4
R G R B
10 5 5 2
7
Output:
12 3 2
Explanation:
Day 1: The gardener gets 2 red flowers.
Day 2: The gardener gets 2 red flowers and 1 green flower.
Day 3: The gardener gets 2 red flowers and 1 blue flower.
Day 4: The gardener gets 2 red flowers and 1 green flower.
Day 5: The gardener gets 2 red flowers.
Day 6: The gardener gets 1 red flower, 1 green flower and 1 blue flower.
Day 7: The gardener gets 1 red flower.
Total number of red flowers = 12.
Total number of green flowers = 3.
Total number of blue flowers = 2.
Hence the output is
12 3 2
Example Input/Output 2:
Input:
7
B G B B B G B
8 2 5 9 1 3 9
10
Output:
0 5 13
Example Input/Output 3:
Input:
8
B B B B B B B B
1 7 4 8 8 1 10 9
13
Output:
0 0 26
N = int(input())
C = input().split()
M = [*map(int, input().split())]
T = int(input())
R = G = B = 0
for i in range(N):
if C[i] == 'R': R += min(M[i], T)
elif C[i] == 'G': G += min(M[i], T // 2)
else: B += min(M[i], T // 3)
print(R, G, B)