結果

問題 No.1046 Fruits Rush
ユーザー hal-XDhal-XD
提出日時 2020-05-09 17:11:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 8,656 KB
最終ジャッジ日時 2023-09-20 01:54:16
合計ジャッジ時間 1,179 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,492 KB
testcase_01 AC 16 ms
8,608 KB
testcase_02 AC 18 ms
8,464 KB
testcase_03 AC 19 ms
8,508 KB
testcase_04 AC 18 ms
8,544 KB
testcase_05 AC 18 ms
8,532 KB
testcase_06 AC 17 ms
8,500 KB
testcase_07 AC 17 ms
8,636 KB
testcase_08 AC 18 ms
8,616 KB
testcase_09 AC 17 ms
8,452 KB
testcase_10 AC 17 ms
8,536 KB
testcase_11 AC 17 ms
8,500 KB
testcase_12 AC 17 ms
8,500 KB
testcase_13 AC 17 ms
8,656 KB
testcase_14 AC 17 ms
8,628 KB
testcase_15 AC 17 ms
8,512 KB
testcase_16 AC 17 ms
8,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#import numpy as np
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(100)

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

fruit = sorted(A , reverse= True)
delicious = 0
index = 0
number_fruit = 0
while  number_fruit < k and index < n:
    if fruit[index] > 0 :
        delicious += fruit[index]
        number_fruit += 1
    else:
        break
    index += 1

if number_fruit == 0:
    delicious += fruit[0]

print(delicious)

    
0