結果

問題 No.1046 Fruits Rush
ユーザー neterukunneterukun
提出日時 2020-05-08 21:24:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 71,632 KB
最終ジャッジ日時 2023-09-17 01:24:14
合計ジャッジ時間 2,192 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,412 KB
testcase_01 AC 64 ms
71,632 KB
testcase_02 AC 65 ms
71,416 KB
testcase_03 AC 64 ms
71,280 KB
testcase_04 AC 66 ms
71,524 KB
testcase_05 AC 63 ms
71,320 KB
testcase_06 AC 66 ms
71,300 KB
testcase_07 AC 66 ms
71,436 KB
testcase_08 AC 64 ms
71,420 KB
testcase_09 AC 66 ms
71,480 KB
testcase_10 AC 67 ms
71,284 KB
testcase_11 AC 65 ms
71,292 KB
testcase_12 AC 65 ms
71,424 KB
testcase_13 AC 64 ms
71,416 KB
testcase_14 AC 63 ms
71,424 KB
testcase_15 AC 63 ms
71,132 KB
testcase_16 AC 63 ms
71,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

a = sorted(a, reverse=True)
ans = 0
cnt = 0
for i in range(k):
    if a[i] > 0:
        ans += a[i]
        cnt += 1

if cnt == 0:
    ans += a[0]
print(ans)
0