結果

問題 No.1512 作文
ユーザー ああいいああいい
提出日時 2022-03-12 14:07:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 78,412 KB
最終ジャッジ日時 2023-10-15 03:10:37
合計ジャッジ時間 7,384 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,516 KB
testcase_01 AC 74 ms
71,316 KB
testcase_02 AC 75 ms
71,280 KB
testcase_03 AC 81 ms
71,472 KB
testcase_04 AC 189 ms
77,644 KB
testcase_05 AC 149 ms
77,516 KB
testcase_06 AC 150 ms
77,432 KB
testcase_07 AC 153 ms
77,384 KB
testcase_08 AC 151 ms
77,460 KB
testcase_09 AC 77 ms
71,364 KB
testcase_10 AC 75 ms
71,336 KB
testcase_11 AC 75 ms
71,528 KB
testcase_12 AC 73 ms
71,452 KB
testcase_13 AC 76 ms
71,416 KB
testcase_14 AC 121 ms
77,480 KB
testcase_15 AC 163 ms
78,412 KB
testcase_16 AC 125 ms
77,544 KB
testcase_17 AC 119 ms
77,448 KB
testcase_18 AC 123 ms
77,532 KB
testcase_19 AC 121 ms
77,348 KB
testcase_20 AC 122 ms
77,524 KB
testcase_21 AC 78 ms
71,380 KB
testcase_22 AC 75 ms
71,416 KB
testcase_23 AC 76 ms
71,384 KB
testcase_24 AC 75 ms
71,532 KB
testcase_25 AC 76 ms
71,332 KB
testcase_26 AC 74 ms
71,272 KB
testcase_27 AC 73 ms
71,412 KB
testcase_28 AC 77 ms
71,284 KB
testcase_29 AC 74 ms
71,412 KB
testcase_30 AC 75 ms
71,120 KB
testcase_31 AC 78 ms
75,876 KB
testcase_32 AC 78 ms
76,076 KB
testcase_33 AC 78 ms
75,840 KB
testcase_34 AC 81 ms
75,792 KB
testcase_35 AC 81 ms
76,352 KB
testcase_36 AC 81 ms
76,288 KB
testcase_37 AC 80 ms
75,976 KB
testcase_38 AC 83 ms
76,336 KB
testcase_39 AC 87 ms
76,444 KB
testcase_40 AC 158 ms
77,208 KB
testcase_41 AC 165 ms
77,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

dat = [[0] * 26 for _ in range(26)]

for _ in range(N):
    S = input()
    flag = True
    for i in range(len(S) - 1):
        if S[i] > S[i+1]:
            flag = False
            break
    if flag:
        c = ord(S[0]) - ord('a')
        cc = ord(S[-1]) - ord('a')
        if c == cc:
            dat[c][c] += len(S)
        else:
            dat[c][cc] = max(dat[c][cc],len(S))
            
dp = [0] * 26
dp[0] = dat[0][0]
for i in range(26):
    for k in range(i+1,26):
        dp[k] = max(dp[k],dp[i] + dat[i][k] + dat[k][k])
print(max(dp))
0