結果

問題 No.1046 Fruits Rush
ユーザー hal-XD
提出日時 2020-05-09 17:11:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-05 22:14:22
合計ジャッジ時間 1,155 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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