Problem Description Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. |
Input Input contains multiple test cases. Each test case is described in a line as follow: N value_1 value_2 …value_N It is guarantied that N is not more than 1000 and all value_i are in the range of 32-int. A test case starting with 0 terminates the input and this test case is not to be processed. |
Output For each case, print the maximum according to rules, and one line one case. |
Sample Input 3 1 3 24 1 2 3 44 3 3 2 10 |
Sample Output 4103 |
Code View Code 1 #include Key points After solved the before question about DP, I think this question is really a piece of cake. Using one array to mark the inputed number, and using the another array to mark the accumulating number. Each time comparing the sum of the present number and the previous accumulated number with the present accumulated number, you can confirm whether change the present accumulated number or not. |