結果

問題 No.1512 作文
ユーザー nephrologistnephrologist
提出日時 2021-05-21 22:20:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 82,176 KB
最終ジャッジ日時 2024-04-18 15:51:20
合計ジャッジ時間 4,806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,224 KB
testcase_01 AC 36 ms
52,224 KB
testcase_02 AC 46 ms
52,608 KB
testcase_03 AC 46 ms
52,736 KB
testcase_04 AC 149 ms
77,440 KB
testcase_05 AC 142 ms
77,696 KB
testcase_06 AC 143 ms
77,440 KB
testcase_07 AC 148 ms
77,808 KB
testcase_08 AC 142 ms
77,952 KB
testcase_09 AC 70 ms
65,792 KB
testcase_10 AC 74 ms
66,304 KB
testcase_11 AC 69 ms
65,792 KB
testcase_12 AC 76 ms
66,304 KB
testcase_13 AC 71 ms
66,304 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 87 ms
76,108 KB
testcase_21 AC 40 ms
53,120 KB
testcase_22 AC 37 ms
52,736 KB
testcase_23 AC 41 ms
54,016 KB
testcase_24 WA -
testcase_25 AC 41 ms
54,272 KB
testcase_26 AC 37 ms
52,736 KB
testcase_27 AC 36 ms
51,968 KB
testcase_28 AC 36 ms
52,224 KB
testcase_29 AC 36 ms
52,352 KB
testcase_30 AC 42 ms
52,480 KB
testcase_31 AC 37 ms
52,608 KB
testcase_32 WA -
testcase_33 AC 37 ms
52,480 KB
testcase_34 AC 39 ms
55,296 KB
testcase_35 AC 62 ms
82,044 KB
testcase_36 AC 61 ms
82,176 KB
testcase_37 AC 44 ms
67,072 KB
testcase_38 AC 53 ms
70,912 KB
testcase_39 AC 52 ms
71,040 KB
testcase_40 AC 155 ms
76,240 KB
testcase_41 AC 150 ms
76,544 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")
        if num1 == num2:
            atode += len(s)
        else:
            memo[num1].append((num2, len(s)))


for i in range(26):
    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) + atode)

0