21040_AppleTree

2022-5-16 18:18| 发布者: Hocassian| 查看: 37| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504777039300-Problem List-采集的数据-后羿采集器.html

Pro.ID

21040

Title

Apple Tree

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21040

AC

195

Submit

1056

Ratio

18.47%

时间&空间限制

  • Time Limit: 300/100 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    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
    2
    1
    2
    3
    4
    5
    3
    3
    10
    10
    10
    0

    Sample Output

    9
    30

    Source

    样例输入

    5
    2
    1
    2
    3
    4
    5
    3
    3
    10
    10
    10
    0

    样例输出

    9
    30

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部