結果
| 問題 |
No.2329 Nafmo、イカサマをする
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 13:04:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 986 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 82,392 KB |
| 実行使用メモリ | 54,360 KB |
| 最終ジャッジ日時 | 2025-06-12 13:09:15 |
| 合計ジャッジ時間 | 3,400 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 26 |
ソースコード
def main():
import sys
N, M, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split())) if N > 0 else []
if N == 0:
print(0)
return
# Sort A in descending order to easily pick the maximum possible value
sorted_A = sorted(A, reverse=True)
def dfs(remaining, current_sum):
if remaining == 0:
return current_sum
max_val = current_sum # Option to stop drawing
# Find the maximum a that can be added without exceeding M
max_a = None
for a in sorted_A:
if current_sum + a <= M:
max_a = a
break
if max_a is not None:
next_sum = current_sum + max_a
candidate = dfs(remaining - 1, next_sum)
if candidate > max_val:
max_val = candidate
return max_val
result = dfs(K, 0)
print(result)
if __name__ == '__main__':
main()
gew1fw