結果

問題 No.1512 作文
ユーザー lllllll88938494lllllll88938494
提出日時 2022-05-30 20:43:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 392 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 81,880 KB
実行使用メモリ 145,872 KB
最終ジャッジ日時 2023-10-21 00:24:25
合計ジャッジ時間 5,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,560 KB
testcase_01 AC 35 ms
53,560 KB
testcase_02 AC 35 ms
53,560 KB
testcase_03 AC 35 ms
53,560 KB
testcase_04 AC 282 ms
111,076 KB
testcase_05 AC 279 ms
110,680 KB
testcase_06 AC 279 ms
111,064 KB
testcase_07 AC 281 ms
110,700 KB
testcase_08 AC 280 ms
111,128 KB
testcase_09 AC 37 ms
53,560 KB
testcase_10 AC 36 ms
53,560 KB
testcase_11 AC 36 ms
53,560 KB
testcase_12 AC 35 ms
53,560 KB
testcase_13 AC 36 ms
53,560 KB
testcase_14 AC 100 ms
76,324 KB
testcase_15 AC 127 ms
77,436 KB
testcase_16 AC 106 ms
76,336 KB
testcase_17 AC 99 ms
76,304 KB
testcase_18 AC 103 ms
76,316 KB
testcase_19 AC 103 ms
76,304 KB
testcase_20 AC 98 ms
76,300 KB
testcase_21 AC 40 ms
53,560 KB
testcase_22 AC 35 ms
53,560 KB
testcase_23 AC 38 ms
53,560 KB
testcase_24 AC 37 ms
53,560 KB
testcase_25 AC 37 ms
53,560 KB
testcase_26 AC 35 ms
53,560 KB
testcase_27 AC 34 ms
53,560 KB
testcase_28 AC 35 ms
53,560 KB
testcase_29 AC 38 ms
53,560 KB
testcase_30 AC 34 ms
53,560 KB
testcase_31 AC 44 ms
59,652 KB
testcase_32 AC 39 ms
59,652 KB
testcase_33 AC 39 ms
59,648 KB
testcase_34 AC 50 ms
61,920 KB
testcase_35 AC 41 ms
60,096 KB
testcase_36 AC 40 ms
60,096 KB
testcase_37 AC 43 ms
67,980 KB
testcase_38 AC 53 ms
75,432 KB
testcase_39 AC 57 ms
75,672 KB
testcase_40 AC 392 ms
145,872 KB
testcase_41 AC 247 ms
132,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())

s=[]
for i in range(n):
    x=input()
    now=x[0]
    for i in range(1,len(x)):
        if  ord(now) > ord(x[i]):
            break
        now=x[i]
    else:
        s.append(x)
s.sort()

dp=[[-1]*27 for i in range(len(s)+1)]
dp[0][0]=0

for i in range(len(s)):
    for j in range(27):
        if dp[i][j] == -1:
            continue
        dp[i+1][j] = max(dp[i][j],dp[i+1][j])
        
        t = ord(s[i][0])-96
        if t >= j:#当末尾と候補文字先頭を比べる
            t2 = ord(s[i][-1])-96#候補文字末尾の場所に移動する
            dp[i+1][t2] = max(dp[i+1][t2],dp[i][j]+len(s[i]))
            

print(max(dp[-1]))


0