結果

問題 No.1512 作文
ユーザー hir355hir355
提出日時 2021-05-21 21:28:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 398 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 89,600 KB
最終ジャッジ日時 2024-04-18 14:29:00
合計ジャッジ時間 4,757 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,480 KB
testcase_01 AC 41 ms
51,840 KB
testcase_02 AC 41 ms
51,584 KB
testcase_03 AC 41 ms
52,096 KB
testcase_04 AC 165 ms
77,884 KB
testcase_05 AC 166 ms
77,940 KB
testcase_06 AC 163 ms
77,824 KB
testcase_07 AC 154 ms
77,940 KB
testcase_08 AC 146 ms
77,568 KB
testcase_09 AC 74 ms
71,816 KB
testcase_10 AC 77 ms
72,064 KB
testcase_11 AC 74 ms
71,680 KB
testcase_12 AC 82 ms
72,960 KB
testcase_13 AC 80 ms
72,164 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 92 ms
76,160 KB
testcase_21 AC 41 ms
54,400 KB
testcase_22 AC 39 ms
52,352 KB
testcase_23 AC 42 ms
54,400 KB
testcase_24 WA -
testcase_25 AC 44 ms
54,784 KB
testcase_26 AC 39 ms
52,352 KB
testcase_27 AC 37 ms
52,096 KB
testcase_28 AC 37 ms
51,968 KB
testcase_29 AC 41 ms
52,480 KB
testcase_30 AC 40 ms
51,968 KB
testcase_31 AC 40 ms
52,480 KB
testcase_32 WA -
testcase_33 AC 39 ms
52,096 KB
testcase_34 AC 42 ms
55,808 KB
testcase_35 AC 74 ms
89,600 KB
testcase_36 AC 84 ms
89,600 KB
testcase_37 AC 52 ms
71,424 KB
testcase_38 AC 56 ms
71,116 KB
testcase_39 AC 55 ms
71,040 KB
testcase_40 AC 162 ms
75,988 KB
testcase_41 AC 157 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
dp = [0] * 26
g = [[] for _ in range(26)]
ans = 0
for i in range(n):
    s = input()
    if sorted(s) == list(s):
        if s[0] == s[-1]:
            ans += len(s)
        else:
            g[ord(s[0]) - 97].append((ord(s[-1]) - 97, len(s)))
for i in range(25):
    for j, c in g[i]:
        dp[j] = max(dp[j], dp[i] + c)
    dp[i + 1] = max(dp[i + 1], dp[i])
print(dp[-1] + ans)
0