結果

問題 No.1512 作文
ユーザー c-yanc-yan
提出日時 2021-05-21 21:56:39
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 86,556 KB
最終ジャッジ日時 2023-07-31 15:17:06
合計ジャッジ時間 8,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,388 KB
testcase_01 AC 68 ms
71,476 KB
testcase_02 AC 70 ms
71,280 KB
testcase_03 AC 69 ms
71,116 KB
testcase_04 AC 438 ms
83,148 KB
testcase_05 AC 427 ms
83,796 KB
testcase_06 AC 425 ms
83,356 KB
testcase_07 AC 443 ms
83,592 KB
testcase_08 AC 439 ms
83,148 KB
testcase_09 AC 102 ms
71,480 KB
testcase_10 AC 104 ms
72,072 KB
testcase_11 AC 104 ms
71,636 KB
testcase_12 AC 108 ms
72,408 KB
testcase_13 AC 105 ms
71,448 KB
testcase_14 AC 141 ms
78,260 KB
testcase_15 AC 138 ms
78,448 KB
testcase_16 AC 143 ms
78,188 KB
testcase_17 AC 136 ms
78,408 KB
testcase_18 AC 139 ms
78,376 KB
testcase_19 AC 142 ms
78,588 KB
testcase_20 AC 137 ms
78,620 KB
testcase_21 AC 75 ms
71,388 KB
testcase_22 AC 72 ms
71,276 KB
testcase_23 AC 76 ms
71,412 KB
testcase_24 AC 74 ms
71,116 KB
testcase_25 AC 72 ms
71,500 KB
testcase_26 AC 71 ms
71,212 KB
testcase_27 AC 68 ms
71,276 KB
testcase_28 AC 73 ms
71,484 KB
testcase_29 AC 73 ms
71,356 KB
testcase_30 AC 70 ms
71,484 KB
testcase_31 AC 71 ms
71,164 KB
testcase_32 AC 71 ms
71,312 KB
testcase_33 AC 70 ms
71,292 KB
testcase_34 AC 80 ms
76,356 KB
testcase_35 AC 78 ms
75,008 KB
testcase_36 AC 79 ms
74,916 KB
testcase_37 AC 72 ms
73,220 KB
testcase_38 AC 83 ms
76,584 KB
testcase_39 AC 85 ms
76,500 KB
testcase_40 AC 654 ms
86,556 KB
testcase_41 AC 397 ms
85,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [input() for _ in range(N)]

S.sort()

dp = {}
#for c in 'abcdefghijklmnopqrstuvwxyz':
#    dp[c] = -1
dp[chr(ord('a')-1)]=0

for l in S:
    #print("*", l)
    if ''.join(sorted(l)) != l:
        continue
    lc = l[-1]
    for c in reversed('abcdefghijklmnopqrstuvwxyz'):
        if c not in dp:
            continue
        if l[0] < c:
            continue
        #print(c, dp[lc])
        if lc not in dp:
            dp[lc] = dp[c] + len(l)
        else:
            dp[lc] = max(dp[lc], dp[c] + len(l))
        #print(c, dp[lc])
    if lc not in dp:
        dp[lc] = len(l)
    else:
        dp[lc] = max(dp[lc], len(l))
    #print(l)
    #print(dp)
print(max(dp.values()))
0