結果

問題 No.1512 作文
ユーザー SidewaysOwl
提出日時 2021-11-28 20:15:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 145,876 KB
最終ジャッジ日時 2024-07-01 15:15:42
合計ジャッジ時間 9,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
from collections import defaultdict
d = defaultdict(int)
S = []
d["A"] = 0
for _ in range(n):
    s = list(input())
    S.append([s,s[0],s[-1]])
S.sort(key=lambda x:(x[1],x[2]))
for _ in range(n):
    s,xx,yy = S[_]
    if s != sorted(s):
        continue
    d_k = list(d.keys())
    for k in d_k:
        if s[0] < k:
            pass
        else:
            d[s[-1]] = max(d[k] + len(s),d[s[-1]])
    d[s[-1]] = max(len(s),d[s[-1]])        
print(max(d.values()))
0