結果

問題 No.1512 作文
ユーザー c-yanc-yan
提出日時 2021-05-22 06:37:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 513 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 86,376 KB
最終ジャッジ日時 2024-04-18 17:25:44
合計ジャッジ時間 5,835 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,620 KB
testcase_01 AC 35 ms
53,152 KB
testcase_02 AC 37 ms
52,004 KB
testcase_03 AC 34 ms
52,372 KB
testcase_04 AC 346 ms
83,184 KB
testcase_05 AC 328 ms
83,636 KB
testcase_06 AC 326 ms
83,544 KB
testcase_07 AC 320 ms
83,880 KB
testcase_08 AC 322 ms
83,600 KB
testcase_09 AC 67 ms
64,808 KB
testcase_10 AC 69 ms
65,668 KB
testcase_11 AC 67 ms
65,480 KB
testcase_12 AC 75 ms
65,096 KB
testcase_13 AC 69 ms
65,152 KB
testcase_14 AC 87 ms
76,948 KB
testcase_15 AC 93 ms
76,744 KB
testcase_16 AC 97 ms
76,988 KB
testcase_17 AC 93 ms
76,644 KB
testcase_18 AC 93 ms
76,820 KB
testcase_19 AC 99 ms
76,808 KB
testcase_20 AC 91 ms
76,732 KB
testcase_21 AC 39 ms
53,088 KB
testcase_22 AC 37 ms
53,244 KB
testcase_23 AC 40 ms
54,448 KB
testcase_24 AC 39 ms
53,808 KB
testcase_25 AC 41 ms
53,472 KB
testcase_26 AC 39 ms
53,100 KB
testcase_27 AC 34 ms
52,468 KB
testcase_28 AC 35 ms
52,768 KB
testcase_29 AC 38 ms
52,008 KB
testcase_30 AC 34 ms
52,428 KB
testcase_31 AC 36 ms
52,216 KB
testcase_32 AC 37 ms
53,296 KB
testcase_33 AC 36 ms
52,556 KB
testcase_34 AC 45 ms
62,544 KB
testcase_35 AC 49 ms
64,492 KB
testcase_36 AC 46 ms
63,684 KB
testcase_37 AC 40 ms
58,656 KB
testcase_38 AC 54 ms
73,140 KB
testcase_39 AC 52 ms
73,312 KB
testcase_40 AC 513 ms
86,376 KB
testcase_41 AC 277 ms
85,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin

readline = stdin.readline

az = 'abcdefghijklmnopqrstuvwxyz'

N = int(readline())
S = [readline()[:-1] for _ in range(N)]

dp = {chr(ord('a') - 1): 0}
for l in sorted(S):
    if ''.join(sorted(l)) != l:
        continue
    start = l[0]
    last = l[-1]
    dp.setdefault(last, 0)
    for c in reversed(az):
        if c not in dp:
            continue
        if start < c:
            continue
        dp[last] = max(dp[last], dp[c] + len(l))
    dp[last] = max(dp[last], len(l))
print(max(dp.values()))
0