結果
問題 |
No.437 cwwゲーム
|
ユーザー |
|
提出日時 | 2024-12-26 08:43:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,566 bytes |
コンパイル時間 | 198 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 77,568 KB |
最終ジャッジ日時 | 2024-12-26 08:43:50 |
合計ジャッジ時間 | 10,613 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 WA * 1 |
ソースコード
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]]!=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]]!=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]]!=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]]+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)