結果
問題 | No.437 cwwゲーム |
ユーザー |
|
提出日時 | 2016-10-28 23:58:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 882 bytes |
コンパイル時間 | 116 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-12 08:26:39 |
合計ジャッジ時間 | 2,681 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
def solve(s): flag = [False] * len(s) ans = 0 def loop(i, score): nonlocal flag, ans if i >= len(s) - 2: ans = max(ans, score) return loop(i + 1, score) if s[i] == '0': return if flag[i]: return for j in range(i + 1, len(s) - 1): if s[i] == s[j]: continue if flag[j]: continue flag[j] = True for k in range(j + 1, len(s)): if flag[k]: continue if s[j] != s[k]: continue flag[k] = True tmp = int(s[i] + s[j] + s[k]) loop(i + 1, score + tmp) flag[k] = False flag[j] = False loop(0, 0) return ans s = input() ans = solve(s) print(ans)