結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-12 17:42:11 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 520 bytes |
| 記録 | |
| コンパイル時間 | 478 ms |
| コンパイル使用メモリ | 20,956 KB |
| 実行使用メモリ | 529,968 KB |
| 最終ジャッジ日時 | 2026-03-09 00:36:48 |
| 合計ジャッジ時間 | 129,305 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 1 TLE * 20 MLE * 1 |
ソースコード
#!/usr/bin/env python3
from functools import lru_cache
@lru_cache(maxsize=None)
def box_in(L, W):
W = list(W)
for w in W:
if w > L:
W.remove(w)
if len(W) == 0:
return 0
candidate = []
for w in W:
Wtmp = list(W)
Wtmp.remove(w)
candidate.append(box_in(L - w, tuple(Wtmp)))
if len(candidate) == 0:
return 1
return max(candidate) + 1
L = int(input())
N = int(input())
W = sorted(map(int, input().split()))
print(box_in(L, tuple(W)))