結果

問題 No.1046 Fruits Rush
ユーザー uni_python
提出日時 2020-06-19 00:07:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,344 KB
実行使用メモリ 53,460 KB
最終ジャッジ日時 2024-07-03 13:04:05
合計ジャッジ時間 1,901 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N,K=MI()
    A=LI()
    A.sort(reverse=True)
    ans=A[0]
    for i in range(1,min(N,K)):
        temp=ans+A[i]
        if temp>ans:
            ans=temp
        else:
            break
    print(ans)
    


main()
0