結果
| 問題 | No.1512 作文 |
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2021-05-21 21:55:55 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 1,687 ms / 2,000 ms |
| コード長 | 703 bytes |
| 記録 | |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 19,160 KB |
| 最終ジャッジ日時 | 2026-04-26 10:59:33 |
| 合計ジャッジ時間 | 13,033 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
N = int(input())
S = [input() for _ in range(N)]
S.sort()
dp = {}
#for c in 'abcdefghijklmnopqrstuvwxyz':
# dp[c] = -1
dp[chr(ord('a')-1)]=0
for l in S:
#print("*", l)
if ''.join(sorted(l)) != l:
continue
lc = l[-1]
for c in reversed('abcdefghijklmnopqrstuvwxyz'):
if c not in dp:
continue
if l[0] < c:
continue
#print(c, dp[lc])
if lc not in dp:
dp[lc] = dp[c] + len(l)
else:
dp[lc] = max(dp[lc], dp[c] + len(l))
#print(c, dp[lc])
if lc not in dp:
dp[lc] = len(l)
else:
dp[lc] = max(dp[lc], len(l))
#print(l)
#print(dp)
print(max(dp.values()))
c-yan