結果

問題 No.1512 作文
ユーザー tamatotamato
提出日時 2021-05-21 21:33:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 119,372 KB
最終ジャッジ日時 2024-04-18 14:42:33
合計ジャッジ時間 5,537 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,992 KB
testcase_01 AC 37 ms
52,336 KB
testcase_02 AC 38 ms
52,672 KB
testcase_03 AC 36 ms
52,196 KB
testcase_04 AC 314 ms
100,176 KB
testcase_05 AC 300 ms
100,568 KB
testcase_06 AC 273 ms
98,520 KB
testcase_07 AC 280 ms
99,804 KB
testcase_08 AC 317 ms
100,020 KB
testcase_09 AC 74 ms
70,548 KB
testcase_10 AC 77 ms
70,196 KB
testcase_11 AC 74 ms
71,092 KB
testcase_12 AC 79 ms
70,556 KB
testcase_13 AC 76 ms
70,500 KB
testcase_14 AC 86 ms
76,776 KB
testcase_15 AC 83 ms
76,180 KB
testcase_16 AC 83 ms
76,284 KB
testcase_17 AC 84 ms
76,528 KB
testcase_18 AC 81 ms
76,052 KB
testcase_19 AC 82 ms
76,320 KB
testcase_20 AC 88 ms
76,528 KB
testcase_21 AC 42 ms
59,524 KB
testcase_22 AC 41 ms
58,872 KB
testcase_23 AC 43 ms
60,536 KB
testcase_24 AC 43 ms
60,232 KB
testcase_25 AC 43 ms
59,924 KB
testcase_26 AC 37 ms
54,460 KB
testcase_27 AC 38 ms
54,248 KB
testcase_28 AC 36 ms
52,952 KB
testcase_29 AC 37 ms
52,764 KB
testcase_30 AC 38 ms
52,820 KB
testcase_31 AC 40 ms
57,800 KB
testcase_32 AC 41 ms
58,544 KB
testcase_33 AC 41 ms
59,332 KB
testcase_34 AC 42 ms
61,604 KB
testcase_35 AC 66 ms
84,224 KB
testcase_36 AC 65 ms
84,908 KB
testcase_37 AC 49 ms
72,200 KB
testcase_38 AC 57 ms
75,024 KB
testcase_39 AC 56 ms
74,380 KB
testcase_40 AC 407 ms
119,372 KB
testcase_41 AC 221 ms
118,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    T = []
    for _ in range(N):
        S = input().rstrip('\n')
        S = [s for s in S]
        SS = sorted(S)
        if S == SS:
            T.append((S[0], S[-1], len(S)))
    for i in range(25):
        T.append((chr(i+97), chr(i+98), 0))
    T.sort(key=lambda x: x[1])
    T.sort(key=lambda x: x[0])
    dp = [0] * 26
    for a, b, l in T:
        aa = ord(a) - 97
        bb = ord(b) - 97
        dp[bb] = max(dp[bb], dp[aa] + l)
    print(max(dp))


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