結果

問題 No.29 パワーアップ
ユーザー roiti46roiti46
提出日時 2015-02-09 22:15:31
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 687 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 77,428 KB
実行使用メモリ 125,816 KB
最終ジャッジ日時 2023-09-05 21:24:37
合計ジャッジ時間 14,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
81,456 KB
testcase_01 AC 79 ms
78,500 KB
testcase_02 AC 92 ms
79,028 KB
testcase_03 TLE -
testcase_04 AC 91 ms
79,196 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
def dfs(item,d):
    if tuple(item) in memo: return memo[tuple(item)]
    res = 0
    for i in range(10):
        if item[i] >= 2:
            nitem = item[:]
            nitem[i] -= 2
            res = max(res,dfs(nitem[:],d+1))
    for select in itertools.combinations(range(10),4):
        if all(item[i] >= 1 for i in select):
            nitem = item[:]
            for i in select: nitem[i] -= 1
            res = max(res,dfs(nitem[:],d+1))
    res = max(res,d)
    memo[tuple(item)] = res
    return res
    
N = int(raw_input())
item = [0]*10
for loop in xrange(N):
    for i in map(int,raw_input().split()):
        item[i-1] += 1
memo = {}
print dfs(item[:],0)
0