結果
問題 | No.1512 作文 |
ユーザー |
![]() |
提出日時 | 2025-04-15 22:19:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 799 bytes |
コンパイル時間 | 354 ms |
コンパイル使用メモリ | 81,832 KB |
実行使用メモリ | 118,660 KB |
最終ジャッジ日時 | 2025-04-15 22:20:49 |
合計ジャッジ時間 | 4,349 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 17 |
ソースコード
n = int(input()) good_strings = [] for _ in range(n): s = input().strip() is_good = True for i in range(1, len(s)): if s[i] < s[i-1]: is_good = False break if is_good and len(s) > 0: start = s[0] end = s[-1] length = len(s) good_strings.append((start, end, length)) dp = [0] * 26 max_dp = [0] * 26 for start_char, end_char, l in good_strings: s0 = ord(start_char) - ord('a') sn = ord(end_char) - ord('a') current_max_prev = max_dp[s0] candidate = current_max_prev + l if candidate > dp[sn]: dp[sn] = candidate # Update max_dp current_max = 0 for i in range(26): if dp[i] > current_max: current_max = dp[i] max_dp[i] = current_max print(max_dp[-1])