結果

問題 No.1046 Fruits Rush
ユーザー wattaiheiwattaihei
提出日時 2020-05-08 21:50:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 253 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 10,644 KB
実行使用メモリ 7,912 KB
最終ジャッジ日時 2023-09-17 02:34:45
合計ジャッジ時間 1,453 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,772 KB
testcase_01 AC 12 ms
7,780 KB
testcase_02 AC 12 ms
7,788 KB
testcase_03 AC 12 ms
7,840 KB
testcase_04 AC 12 ms
7,884 KB
testcase_05 AC 12 ms
7,708 KB
testcase_06 AC 12 ms
7,880 KB
testcase_07 AC 13 ms
7,912 KB
testcase_08 AC 12 ms
7,836 KB
testcase_09 AC 11 ms
7,820 KB
testcase_10 AC 13 ms
7,768 KB
testcase_11 AC 11 ms
7,828 KB
testcase_12 AC 12 ms
7,828 KB
testcase_13 AC 12 ms
7,828 KB
testcase_14 AC 12 ms
7,780 KB
testcase_15 AC 11 ms
7,840 KB
testcase_16 AC 12 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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