結果
| 問題 |
No.2329 Nafmo、イカサマをする
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:14:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 793 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 54,040 KB |
| 最終ジャッジ日時 | 2025-04-15 21:20:36 |
| 合計ジャッジ時間 | 2,635 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 26 |
ソースコード
n, m, k = map(int, input().split())
a = list(map(int, input().split())) if n > 0 else []
if n == 0:
print(0)
else:
a_sorted = sorted(a, reverse=True)
dp = [0] * (k + 1)
for i in range(1, k + 1):
if dp[i-1] == -1:
dp[i] = -1
continue
current_sum = dp[i-1]
remaining = m - current_sum
if remaining < 0:
dp[i] = -1
continue
selected_a = None
for num in a_sorted:
if num <= remaining:
selected_a = num
break
if selected_a is not None:
dp[i] = current_sum + selected_a
else:
dp[i] = -1
max_sum = 0
for s in dp:
if s <= m and s > max_sum:
max_sum = s
print(max_sum)
lam6er