結果
| 問題 |
No.27 板の準備
|
| コンテスト | |
| ユーザー |
ckawatak
|
| 提出日時 | 2017-09-20 20:14:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 52,608 KB |
| 最終ジャッジ日時 | 2024-11-08 09:14:25 |
| 合計ジャッジ時間 | 1,893 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 15 |
ソースコード
from itertools import combinations_with_replacement
def partition(n, ns, p):
integers = []
for i in range(1, len(ns)+2):
for j in combinations_with_replacement(ns, i):
integers.append(j)
found = False
for integer in integers:
if sum(integer) == n:
p[n] = integer
found = True
break
if not found:
p[n] = (n,)
boards = list(map(int, input().split(' ')))
boards.sort()
N = len(boards)
partitions = {}
for i in reversed(range(N-1)):
board = boards[i]
partition(board, boards[:i], partitions)
solution = 0
for p in partitions:
solution += len(partitions[p])
print(solution+1)
ckawatak