結果
問題 |
No.1512 作文
|
ユーザー |
![]() |
提出日時 | 2021-05-21 21:55:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 23,624 KB |
最終ジャッジ日時 | 2024-10-10 08:32:09 |
合計ジャッジ時間 | 15,190 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 36 TLE * 1 -- * 1 |
ソースコード
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()))