Pro.ID21040 TitleApple Tree Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21040 AC195 Submit1056 Ratio18.47% 时间&空间限制描述There are so many problems called "Apple Tree", includeing the one you are reading now. After 钟Sir goes back home, he finds that all his grandpa's apple trees go ripe. He is so happy and wants to pick some apples back to his school and shares them with all his students. Assume all the trees are in a line. To stop 钟Sir from picking all the apples, his grandpa asks him to pick from k trees. So 钟Sir asks you, a genius programer, to help him find out how many apples could he pick at most. 输入There are mutiple test cases. In the first line of each test case there is only one interger N, indicating the number of grandpa's apple trees. Here 0 < N ≤ 1000. line with N = 0 indicating the end of the input file. In the second line of each test case there is only one positive integer K, which is described above. In the next N lines there is one integer Ai per line, which is the number of apples in the i-th tree. Here 0 < Ai ≤ 100. 输出Description There are so many problems called "Apple Tree", includeing the one you are reading now. After 钟Sir goes back home, he finds that all his grandpa's apple trees go ripe. He is so happy and wants to pick some apples back to his school and shares them with all his students. Assume all the trees are in a line. To stop 钟Sir from picking all the apples, his grandpa asks him to pick from k trees. So 钟Sir asks you, a genius programer, to help him find out how many apples could he pick at most. Input There are mutiple test cases. In the first line of each test case there is only one interger N, indicating the number of grandpa's apple trees. Here 0 < N ≤ 1000. line with N = 0 indicating the end of the input file. In the second line of each test case there is only one positive integer K, which is described above. In the next N lines there is one integer Ai per line, which is the number of apples in the i-th tree. Here 0 < Ai ≤ 100. Output For each case, output one line with only one number which is the maximum apples 钟Sir can pick. Sample Input 5 Sample Output 9 Source 样例输入5 样例输出9 提示作者 |