結果

問題 No.1512 作文
ユーザー 👑 tamatotamato
提出日時 2021-05-21 21:33:05
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 87,620 KB
実行使用メモリ 121,044 KB
最終ジャッジ日時 2023-07-31 14:40:44
合計ジャッジ時間 7,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,660 KB
testcase_01 AC 74 ms
71,676 KB
testcase_02 AC 72 ms
71,708 KB
testcase_03 AC 72 ms
71,500 KB
testcase_04 AC 343 ms
99,844 KB
testcase_05 AC 342 ms
100,216 KB
testcase_06 AC 349 ms
100,228 KB
testcase_07 AC 345 ms
100,204 KB
testcase_08 AC 344 ms
100,100 KB
testcase_09 AC 106 ms
76,208 KB
testcase_10 AC 109 ms
76,100 KB
testcase_11 AC 106 ms
75,772 KB
testcase_12 AC 112 ms
76,692 KB
testcase_13 AC 109 ms
76,080 KB
testcase_14 AC 116 ms
78,264 KB
testcase_15 AC 115 ms
78,020 KB
testcase_16 AC 114 ms
77,912 KB
testcase_17 AC 115 ms
78,052 KB
testcase_18 AC 113 ms
78,008 KB
testcase_19 AC 112 ms
77,984 KB
testcase_20 AC 116 ms
77,820 KB
testcase_21 AC 79 ms
75,588 KB
testcase_22 AC 78 ms
75,540 KB
testcase_23 AC 79 ms
75,676 KB
testcase_24 AC 79 ms
75,496 KB
testcase_25 AC 79 ms
75,780 KB
testcase_26 AC 73 ms
71,516 KB
testcase_27 AC 72 ms
71,784 KB
testcase_28 AC 73 ms
71,748 KB
testcase_29 AC 72 ms
71,696 KB
testcase_30 AC 72 ms
71,512 KB
testcase_31 AC 76 ms
75,976 KB
testcase_32 AC 76 ms
75,816 KB
testcase_33 AC 76 ms
75,500 KB
testcase_34 AC 78 ms
75,500 KB
testcase_35 AC 98 ms
85,824 KB
testcase_36 AC 97 ms
85,892 KB
testcase_37 AC 82 ms
77,444 KB
testcase_38 AC 85 ms
75,948 KB
testcase_39 AC 85 ms
76,228 KB
testcase_40 AC 459 ms
121,044 KB
testcase_41 AC 294 ms
120,240 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