結果

問題 No.437 cwwゲーム
ユーザー yomo3
提出日時 2020-03-10 16:26:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-15 23:24:14
合計ジャッジ時間 3,007 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

A = list(map(int, input()))
L = len(A)  # 1-13

def solve(used):
    if used == (1 << L) - 1:
        return 0
    res = 0
    for i in range(0, L - 2):
        if used & (1 << i) or A[i] == 0: continue
        for j in range(i + 1, L - 1):
            if used & (1 << j) or A[i] == A[j]: continue
            for k in range(j + 1, L):
                if used & (1 << k) or A[j] != A[k]: continue
                s = A[i] * 100 + A[j] * 10 + A[k]
                s += solve(used | (1 << i) | (1 << j) | (1 << k))
                if s > res:
                    res = s
    return res

ans = solve(0)

print(ans)
0