結果

問題 No.437 cwwゲーム
ユーザー kohei2019
提出日時 2022-01-25 00:40:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 76,760 KB
最終ジャッジ日時 2024-12-15 05:14:17
合計ジャッジ時間 3,796 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = list(input())
ans = 0
dd = collections.defaultdict(lambda:0)
def func(ls):
    if len(ls) < 3:
        dd[''.join(ls)] = 0
        return 0
    s = ''.join(ls)
    if s in dd:
        return dd[s]
    c = len(ls)
    val = 0
    for i in range(c-2):
        for j in range(i+1,c-1):
            for k in range(j+1,c):
                ls0 = ls[:]
                a0,b0,c0 = ls0[i],ls0[k],ls0[j]
                del ls0[i]
                del ls0[j-1]
                del ls0[k-2]
                if a0!=b0 and b0==c0:
                    val = max(val,func(ls0)+int(a0+b0+c0))
                else:
                    val = max(val,func(ls0))
    dd[s] = val
    return val
print(func(N))
0