結果
| 問題 | No.1046 Fruits Rush |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-08 22:25:03 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
AC
|
| 実行時間 | 105 ms / 2,000 ms |
| コード長 | 357 bytes |
| 記録 | |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 15,360 KB |
| 最終ジャッジ日時 | 2026-03-25 08:54:54 |
| 合計ジャッジ時間 | 3,475 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, k, *a = map(int, read().split())
a.sort()
ans = max(a)
for i in range(n):
if a[0] < 0:
a.pop(0)
else:
break
if a:
a.sort(reverse=True)
print(sum(a[:k]))
else:
print(ans)