結果

問題 No.1046 Fruits Rush
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-08 21:23:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 71,564 KB
最終ジャッジ日時 2023-09-17 01:18:47
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,316 KB
testcase_01 AC 58 ms
71,216 KB
testcase_02 AC 59 ms
71,040 KB
testcase_03 AC 61 ms
71,292 KB
testcase_04 AC 61 ms
71,320 KB
testcase_05 AC 60 ms
71,256 KB
testcase_06 AC 62 ms
71,196 KB
testcase_07 AC 60 ms
71,480 KB
testcase_08 AC 62 ms
71,240 KB
testcase_09 AC 61 ms
71,432 KB
testcase_10 AC 60 ms
71,112 KB
testcase_11 AC 63 ms
71,504 KB
testcase_12 AC 63 ms
71,220 KB
testcase_13 AC 61 ms
71,212 KB
testcase_14 AC 61 ms
71,280 KB
testcase_15 AC 62 ms
71,124 KB
testcase_16 AC 63 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(k):
    if i == 0:
        ans += A[i]
    else:
        if A[i] >= 0:
            ans += A[i]
        else:
            break
print(ans)
0