結果
| 問題 | No.1512 作文 |
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2021-05-21 21:55:55 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,627 ms / 2,000 ms |
| + 901µs | |
| コード長 | 703 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 15,828 KB |
| 最終ジャッジ日時 | 2026-09-13 03:11:58 |
| 合計ジャッジ時間 | 10,564 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_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