Karan and his School Assignment
All submissions for this problem are available.
As board exams are coming close, Karan school teacher gave him an assignment consist of n topics he has to revise it by practicing questions for boards exams. Each topic consists of a[i] questions. Karan’s teacher asked him to solve all questions in pairs and submit his assignment.Karan decided to either solve questions of same topic or of adjacent topics. For solving each question, he takes k minutes. If he solves questions of different topics he will take extra r minutes to solve each question. Karan is not able to estimate time he will take to complete his assignment, so he asks you to find in what minimum time he will be able solve his assignment given by his teacher if he is not able to solve print -1.
The first line contains positive integer T represents the no of test cases in the input file. Each test case contains 3 space separated integer n, k and r. Next line contain n space separated integers.
For each test case print minimum time Karan will take to solve his assignment. If he is not able to solve his assignment print -1.
1≤ T ≤ 1000
1 ≤ n ≤ 10^5
1≤ k, r≤10^3
0 ≤ a[i] ≤ 10^9
Input: 2 4 1 1 1 1 2 2 3 2 1 1 1 1 Output: 8 -1
Example case 1. For a and a karan takes 4 minutes 2 for each as he practice questions of different topics and for a and a he takes 4 minutes 1 for each question
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYPY|
Fetching successful submissions