結果
| 問題 | No.1046 Fruits Rush | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-02-12 09:51:27 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 39 ms / 2,000 ms | 
| コード長 | 234 bytes | 
| コンパイル時間 | 373 ms | 
| コンパイル使用メモリ | 82,116 KB | 
| 実行使用メモリ | 53,684 KB | 
| 最終ジャッジ日時 | 2024-06-28 11:39:27 | 
| 合計ジャッジ時間 | 1,718 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
n,k = map(int,input().split())
an = sorted(list(map(int,input().split())))[::-1]
count = an[0]
i_c = 1
for i in range(1,len(an)):
    if an[i]<0 or i_c>=k:
        break
    else:
        count+=an[i]
        i_c+=1
print(count)
    
            
            
            
        