In a car factory there are two assembly lines, called A and B. Each of them consists of N positions numbered from 0 to N-1. In each position, some component is installed into the car being assembled. The lines are
symmetric; that is, the same component is installed into the car in the corresponding positions of A and B.
In order to assemble a car, it needs to get through all of the positions on the assembly lines. It takes A[K] minutes to install the component in the K-th position on line A, and B[K] minutes to install it on line B.
After installing a component in the K-th position, the car can either be moved to the next position on the same line (which happens automatically and takes 0 minutes) or it can be moved to the other line. Switching from line A to line B takes X minutes, and switching from line B to line A takes Y minutes.
The assembly process can be started in either line.
Write a function:
class Solution { public int solution (int[] A, int[] B, int X, int Y); }
that, given arrays A and B consisting of N integers each, and integers X and Y, returns the minimum time required to assemble an entire car.