結果

問題 No.437 cwwゲーム
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-10-28 23:19:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2023-08-15 21:35:05
合計ジャッジ時間 7,081 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,348 KB
testcase_01 AC 94 ms
71,616 KB
testcase_02 AC 96 ms
71,724 KB
testcase_03 AC 95 ms
71,160 KB
testcase_04 AC 95 ms
71,436 KB
testcase_05 AC 99 ms
71,420 KB
testcase_06 AC 98 ms
71,164 KB
testcase_07 AC 107 ms
77,008 KB
testcase_08 AC 104 ms
76,840 KB
testcase_09 AC 111 ms
77,188 KB
testcase_10 AC 110 ms
77,348 KB
testcase_11 AC 96 ms
71,520 KB
testcase_12 AC 97 ms
71,468 KB
testcase_13 AC 96 ms
71,372 KB
testcase_14 AC 94 ms
71,456 KB
testcase_15 AC 111 ms
76,840 KB
testcase_16 AC 96 ms
71,384 KB
testcase_17 AC 97 ms
71,584 KB
testcase_18 AC 100 ms
71,524 KB
testcase_19 AC 98 ms
71,520 KB
testcase_20 AC 95 ms
71,640 KB
testcase_21 AC 96 ms
71,620 KB
testcase_22 AC 96 ms
71,164 KB
testcase_23 AC 95 ms
71,384 KB
testcase_24 AC 99 ms
71,376 KB
testcase_25 AC 98 ms
71,652 KB
testcase_26 WA -
testcase_27 AC 93 ms
71,376 KB
testcase_28 AC 100 ms
71,128 KB
testcase_29 AC 95 ms
71,560 KB
testcase_30 AC 99 ms
71,520 KB
testcase_31 AC 98 ms
71,480 KB
testcase_32 AC 98 ms
71,624 KB
testcase_33 AC 99 ms
71,652 KB
testcase_34 AC 100 ms
71,644 KB
testcase_35 AC 98 ms
71,488 KB
testcase_36 AC 95 ms
71,284 KB
testcase_37 AC 95 ms
71,524 KB
testcase_38 AC 96 ms
71,652 KB
testcase_39 AC 95 ms
71,612 KB
testcase_40 AC 97 ms
71,516 KB
testcase_41 AC 97 ms
71,720 KB
testcase_42 AC 97 ms
71,640 KB
testcase_43 AC 95 ms
71,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import collections
import itertools
import sys


REC_LIMIT = 10000
UNDEF = -1


def is_cww(s):
    return len(s) == 3 and "0" != s[0] and s[0] != s[1] and s[1] == s[2]


def solve(n):
    dp = collections.defaultdict(lambda: UNDEF)

    def rec(x0):
        if dp[x0] != UNDEF:
            return dp[x0]
        score = 0
        for i, j, k in itertools.combinations(range(len(x0)), 3):
            y = x0[i] + x0[j] + x0[k]
            if not is_cww(y):
                continue
            x = x0[:i] + x0[j + 1:k] + x0[k + 1:]
            score = max(score, rec(x) + int(y))
        dp[x0] = score
        return score

    return rec(str(n))


def main():
    sys.setrecursionlimit(REC_LIMIT)
    n = int(input())
    print(solve(n))


if __name__ == '__main__':
    main()
0