結果

問題 No.1512 作文
ユーザー nephrologistnephrologist
提出日時 2021-05-21 22:21:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 88,160 KB
最終ジャッジ日時 2024-04-18 15:52:38
合計ジャッジ時間 5,589 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,876 KB
testcase_01 AC 36 ms
52,964 KB
testcase_02 AC 36 ms
52,316 KB
testcase_03 AC 37 ms
52,768 KB
testcase_04 AC 238 ms
81,908 KB
testcase_05 AC 237 ms
81,816 KB
testcase_06 AC 234 ms
81,872 KB
testcase_07 AC 234 ms
81,904 KB
testcase_08 AC 233 ms
82,264 KB
testcase_09 AC 69 ms
66,180 KB
testcase_10 AC 72 ms
66,556 KB
testcase_11 AC 70 ms
66,712 KB
testcase_12 AC 75 ms
66,816 KB
testcase_13 AC 71 ms
67,124 KB
testcase_14 AC 89 ms
76,284 KB
testcase_15 AC 92 ms
76,440 KB
testcase_16 AC 91 ms
76,500 KB
testcase_17 AC 89 ms
76,296 KB
testcase_18 AC 89 ms
76,176 KB
testcase_19 AC 89 ms
76,368 KB
testcase_20 AC 100 ms
76,084 KB
testcase_21 AC 46 ms
53,508 KB
testcase_22 AC 38 ms
54,736 KB
testcase_23 AC 41 ms
54,064 KB
testcase_24 AC 40 ms
54,576 KB
testcase_25 AC 40 ms
55,344 KB
testcase_26 AC 36 ms
54,060 KB
testcase_27 AC 36 ms
52,888 KB
testcase_28 AC 36 ms
52,616 KB
testcase_29 AC 36 ms
52,488 KB
testcase_30 AC 36 ms
52,572 KB
testcase_31 AC 37 ms
53,436 KB
testcase_32 AC 37 ms
54,120 KB
testcase_33 AC 36 ms
53,204 KB
testcase_34 AC 39 ms
55,172 KB
testcase_35 AC 61 ms
81,792 KB
testcase_36 AC 61 ms
82,296 KB
testcase_37 AC 44 ms
68,168 KB
testcase_38 AC 53 ms
71,068 KB
testcase_39 AC 52 ms
71,048 KB
testcase_40 AC 209 ms
88,160 KB
testcase_41 AC 193 ms
87,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right

n = int(input())
memo = [[] for _ in range(26)]
dp = [0] * 26
atode = 0
for _ in range(n):
    s = list(input())
    if sorted(s) == s:
        num1 = ord(s[0]) - ord("a")
        num2 = ord(s[-1]) - ord("a")
        memo[num1].append((num2, len(s)))


for i in range(26):
    memo[i].sort()
    dp[i] = max(dp[: (i + 1)])
    for a, b in memo[i]:
        dp[a] = max(dp[a], dp[i] + b)
    # print(dp)

print(max(dp))

0