結果

問題 No.1046 Fruits Rush
ユーザー 蕎麦屋
提出日時 2020-05-08 21:52:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 249 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-07-04 00:31:51
合計ジャッジ時間 1,354 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
count = 0
ans = 0
for i in a:
    if((i>=1 and count<k) or count == 0):
        count+=1
        ans+=i
    if(i<=0):
        break
#print(a)
print(ans)
0