結果
問題 |
No.2329 Nafmo、イカサマをする
|
ユーザー |
![]() |
提出日時 | 2025-04-16 15:31:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 793 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 81,956 KB |
実行使用メモリ | 54,100 KB |
最終ジャッジ日時 | 2025-04-16 15:36:29 |
合計ジャッジ時間 | 2,836 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)