Pro.ID22134 TitleStock Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22134 AC5 Submit69 Ratio7.25% 时间&空间限制描述Everybody wants to find out the "Stock God" Buffett second in China. Warren Buffett invests his money to the stock which is valuable in long-term, no matter how low or high the price is currently. And he sales his stock in reason when the risk accumulated to a high level, no matter how booming the stock market looks like. I want to be Buffett II, so I learned from Buffett in investment. In fact, Buffett also do short-term business sometimes. One day, he gives me such a problem. "Now I'm focusing on a stock, if I know the price in every second, can you tell me the maximum profit I can get in a period of time?" "First, let me introduce some basic theory to you. Every time, you could buy, sell, or hold your stocks as you like." "When you buy the stock, you could only buy X (X is a positive integer) Round Lots of a stock (1 Round Lot = 100 shares), then you have to pay the bill, which is G = Current_Price * X * 100." "When you sell, you could sell any Y rounds you have now, then you get your cash, G = Current_Price * Y * 100." "But notice that both bought and sold, you have to pay the fees. There are two kinds of fees. One is that you should pay the stamp-duty, the rate of stamp-duty is T (for instance, 0.003 nowadays), that means you should pay more G * T when you bought or sold." "The other kind is that you should pay the securities transaction tax, it is somewhat similar to stamp-duty. It also has the rate S1 (for example, 0.001), but it has a minimum bound requirement S2 (for example, 5 RMB), that means you have to pay more Max (G * S1, S2) when you bought or sold." "You should notice that, you cannot overdraw the cash, so your spare cash must greater or equal to 0." "Initially, I will have some funds to you, after N period of time, you should make maximum profit to me. I need my funds to do other investment, so I want the maximum cash, not value of shares." 输入The first line of input there is one integer t ( t ≤ 50 ), giving the number of test cases in the input. Each test case starts with 4 real number C ( 0 < C ≤ 1000000 ), S1 ( 0.0001 < S1 < 0.01 ), S2 ( 1 ≤ S2 ≤ 100 ), T ( 0.0001 < T < 0.01 ), representing the initial funds C, securities transaction tax S1 and S2, stamp-duty T. Next line contains a integer N ( 0 < N ≤ 30000 ), period of time. Then a line comes with N real number, representing the price in each second. 输出Description Everybody wants to find out the "Stock God" Buffett second in China. Warren Buffett invests his money to the stock which is valuable in long-term, no matter how low or high the price is currently. And he sales his stock in reason when the risk accumulated to a high level, no matter how booming the stock market looks like. I want to be Buffett II, so I learned from Buffett in investment. In fact, Buffett also do short-term business sometimes. One day, he gives me such a problem. "Now I'm focusing on a stock, if I know the price in every second, can you tell me the maximum profit I can get in a period of time?" "First, let me introduce some basic theory to you. Every time, you could buy, sell, or hold your stocks as you like." "When you buy the stock, you could only buy X (X is a positive integer) Round Lots of a stock (1 Round Lot = 100 shares), then you have to pay the bill, which is G = Current_Price * X * 100." "When you sell, you could sell any Y rounds you have now, then you get your cash, G = Current_Price * Y * 100." "But notice that both bought and sold, you have to pay the fees. There are two kinds of fees. One is that you should pay the stamp-duty, the rate of stamp-duty is T (for instance, 0.003 nowadays), that means you should pay more G * T when you bought or sold." "The other kind is that you should pay the securities transaction tax, it is somewhat similar to stamp-duty. It also has the rate S1 (for example, 0.001), but it has a minimum bound requirement S2 (for example, 5 RMB), that means you have to pay more Max (G * S1, S2) when you bought or sold." "You should notice that, you cannot overdraw the cash, so your spare cash must greater or equal to 0." "Initially, I will have some funds to you, after N period of time, you should make maximum profit to me. I need my funds to do other investment, so I want the maximum cash, not value of shares." Input The first line of input there is one integer t ( t ≤ 50 ), giving the number of test cases in the input. Each test case starts with 4 real number C ( 0 < C ≤ 1000000 ), S1 ( 0.0001 < S1 < 0.01 ), S2 ( 1 ≤ S2 ≤ 100 ), T ( 0.0001 < T < 0.01 ), representing the initial funds C, securities transaction tax S1 and S2, stamp-duty T. Next line contains a integer N ( 0 < N ≤ 30000 ), period of time. Then a line comes with N real number, representing the price in each second. Output For each test case, output one real number, rounded to 0.001, which is the maximum profit you make. The answer is less than 1e15 . Sample Input 1 Sample Output 5332.000 Hint Source 样例输入1 样例输出5332.000 提示 |