結果
問題 |
No.1512 作文
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:47:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 801 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 82,532 KB |
実行使用メモリ | 130,412 KB |
最終ジャッジ日時 | 2025-06-12 13:48:25 |
合計ジャッジ時間 | 4,759 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 17 |
ソースコード
n = int(input()) strings = [input().strip() for _ in range(n)] valid = [] for s in strings: if len(s) == 0: continue is_sorted = True prev = s[0] for c in s[1:]: if c < prev: is_sorted = False break prev = c if is_sorted: valid.append((s[0], s[-1], len(s))) dp = [0] * 26 max_dp = [0] * 26 for s_start, s_end, len_s in valid: s_start_idx = ord(s_start) - ord('a') s_end_idx = ord(s_end) - ord('a') max_prev = max_dp[s_start_idx] new_length = max_prev + len_s if new_length > dp[s_end_idx]: dp[s_end_idx] = new_length # Update max_dp current_max = 0 for i in range(26): current_max = max(current_max, dp[i]) max_dp[i] = current_max print(max(dp))