結果

問題 No.437 cwwゲーム
ユーザー flippergo
提出日時 2024-12-26 09:49:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,078 ms / 2,000 ms
コード長 1,634 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2024-12-26 09:50:01
合計ジャッジ時間 8,295 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations
N = list(input())
L = list(range(len(N)))
ans = 0
if len(L)<3:
    print(0)
else:
    for x in combinations(L,3):
        cnt = 0
        x1 = N[x[0]]+N[x[1]]+N[x[2]]
        if N[x[0]]!="0" and N[x[0]]!=N[x[1]] and N[x[1]]==N[x[2]]:
            cnt += int(x1)
            ans = max(ans,cnt)
        L1 = []
        for i in L:
            if i not in x:
                L1.append(i)
        if len(L1)<3:
            cnt = 0
            continue
        for y in combinations(L1,3):
            y1 = N[y[0]]+N[y[1]]+N[y[2]]
            cnt1 = cnt
            if N[y[0]]!="0" and N[y[0]]!=N[y[1]] and N[y[1]]==N[y[2]]:
                cnt1 += int(y1)
                ans = max(ans,cnt1)
            L2 = []
            for i in L1:
                if i not in y:
                    L2.append(i)
            if len(L2)<3:
                continue
            for z in combinations(L2,3):
                z1 = N[z[0]]+N[z[1]]+N[z[2]]
                cnt2 = cnt1
                if N[z[0]]!="0" and N[z[0]]!=N[z[1]] and N[z[1]]==N[z[2]]:
                    cnt2 += int(z1)
                    ans = max(ans,cnt2)
                L3 = []
                for i in L2:
                    if i not in z:
                        L3.append(i)
                if len(L3)<3:
                    continue
                for w in combinations(L3,3):
                    w1 = N[w[0]]!="0" and N[w[0]]+N[w[1]]+N[w[2]]
                    cnt3 = cnt2
                    if N[w[0]]!=N[w[1]] and N[w[1]]==N[w[2]]:
                        cnt3 += int(w1)
                        ans = max(ans,cnt3)
    print(ans)
0