結果

問題 No.437 cwwゲーム
コンテスト
ユーザー rlangevin
提出日時 2023-01-15 15:13:38
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 798 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 247 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 81,280 KB
最終ジャッジ日時 2026-06-02 13:46:37
合計ジャッジ時間 5,349 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = list(input())
N = list(map(int, N))
M = len(N)
M2 = 1 << M
dp = [0] * M2
for i in range(M2):
    for a in range(M):
        for b in range(a + 1, M):
            for c in range(b + 1, M):
                if (i >> a) & 1:
                    continue
                if (i >> b) & 1:
                    continue
                if (i >> c) & 1:
                    continue
                if N[a] == 0:
                    continue
                if N[b] != N[c]:
                    continue
                if N[a] == N[b]:
                    continue
                ni = i
                ni |= 1 << a
                ni |= 1 << b
                ni |= 1 << c
                v = int(N[a]*100 + N[b]*10 + N[c])
                dp[ni] = max(dp[ni], dp[i] + v)
print(dp[-1])               
0