結果

問題 No.1046 Fruits Rush
ユーザー tktk_snsn
提出日時 2020-12-16 18:18:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 183 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-09-20 05:12:35
合計ジャッジ時間 1,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

ans = a.pop()
k -= 1

while k:
    if a[-1] < 0:
        break
    ans += a.pop()
    k -= 1

print(ans)
0