Submit | All submissions | Best solutions | Back to list |
WORKB - Working in Beijing |
Mr. M is an undergraduate student of FDU, Shanghai. He finds an intern position in Beijing, so that he cannot attend all the college activities. But in some conditions, he must come back to Shanghai on certain dates. We can assume the important activities that Mr. M must attend occupy a whole day. Mr. M must take a flight to Shanghai before that day and leave after that day. On the other hand, when Mr. M is absent in Beijing and he will lose his salary for his absence.
Sometimes the cost of a flight is much higher than the loss of salary, so to save the cost on the travel, Mr. M can stay in Shanghai to wait for another important date before he returns to Beijing.
Now, Mr. M knows all of the important dates in the next year. Help him schedule his travel to optimize the cost.
Input
The input contains several test cases. The first line of single integer indicates the number of test cases.
For each test case, the first line contains three integers: n, a and b, denoting the number of important events, the cost of a single flight from Beijing to Shanghai or Shanghai to Beijing and the salary for a single day stay in Beijing. (1 ≤ n ≤ 100000, 1 ≤ a ≤ 1000000000, 1 ≤ b ≤100)
Next line contains n integers ti, denoting the dates of the important events. You can assume the ti are in increasing order and they are different from each other. (0 ≤ ti ≤ 10000000)
Output
For each test case, output a single integer indicating the minimum cost for this year.
Example
Input: 2 1 10 10 5 5 10 2 5 10 15 65 70 Output: Case #1: 30 Case #2: 74
Warning: large input/output data, be careful with certain languages.
Added by: | Fudan University Problem Setters |
Date: | 2011-09-08 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Fudan University Local Contest #3, by lcosvse |
hide comments
|
|||||
2013-01-11 12:18:27 Snehasish Roy ;)
Go Greedy :) |
|||||
2012-05-16 14:39:21 Mr. Rook
he goes on a supersonic plane :D |
|||||
2011-09-14 13:47:43 Naman
Make sure to put ans in Case #i format :) Last edit: 2011-09-14 20:49:04 |
|||||
2011-09-08 20:26:10 blashyrkh
@:D Cost doesn't include a positive salary, only a penalty for absence and flights cost. |
|||||
2011-09-08 19:32:56 :D
Re: blashyrkh Yeah, just figured it out, thanks :) Last edit: 2011-09-08 20:50:03 |
|||||
2011-09-08 19:10:00 blashyrkh
Does a traveling occupy a whole day? Answer: no, traveling occupies no time. Last edit: 2011-09-08 19:15:32 |