# Chef in Vaccination Queue solution codechef

Table of Contents

# Chef in Vaccination Queue solution codechef

There are NN people in the vaccination queue, Chef is standing on the PthPth position from the front of the queue. It takes XX minutes to vaccinate a child and YY minutes to vaccinate an elderly person. Assume Chef is an elderly person.

You are given a binary array A1,A2,,ANA1,A2,…,AN of length NN, where Ai=1Ai=1 denotes there is an elderly person standing on the ithith position of the queue, Ai=0Ai=0 denotes there is a child standing on the ithith position of the queue. You are also given the three integers P,X,YP,X,Y. Find the number of minutes after which Chef’s vaccination will be completed.

# Chef in Vaccination Queue solution codechef

• First line will contain TT, number of testcases. Then the testcases follow.
• The first line of each test case contains four space-separated integers N,P,X,YN,P,X,Y.
• The second line of each test case contains NN space-separated integer A1,A2,,ANA1,A2,…,AN.

### Output Format

For each testcase, output in a single line the number of minutes after which Chef’s vaccination will be completed.

### Constraints

• 1T1001≤T≤100
• 1N1001≤N≤100
• 1PN1≤P≤N
• 1X,Y101≤X,Y≤10
• 0Ai10≤Ai≤1
• AP=1AP=1

# Chef in Vaccination Queue solution codechef

3
4 2 3 2
0 1 0 1
3 1 2 3
1 0 1
3 3 2 2
1 1 1


### Sample Output 1

5
3
6


### Explanation

Test case 11: The person standing at the front of the queue is a child and the next person is Chef. So it takes a total of 3+2=53+2=5 minutes to complete Chef’s vaccination.

Test case 22: Chef is standing at the front of the queue. So his vaccination is completed after 33 minutes.

Test case 33: Chef is standing at the rear of the queue. So it takes a total of 2+2+2=62+2+2=6 minutes to complete Chef’s vaccination.