結果
問題 |
No.1512 作文
|
ユーザー |
![]() |
提出日時 | 2021-05-21 22:16:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 549 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 15,728 KB |
最終ジャッジ日時 | 2024-10-10 08:59:55 |
合計ジャッジ時間 | 9,901 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 17 |
ソースコード
def resolve(): n = int(input()) chars = ord("z") - ord("a") + 1 dp = [0] * (chars) next_dp = dp[:] for _ in range(n): s = input() lens = len(s) if list(s) != sorted(list(s)): continue head = ord(s[0]) - ord("a") tail = ord(s[-1]) - ord("a") for i in range(tail): next_dp[i] = dp[i] for i in range(tail, chars): next_dp[i] = max(dp[i], dp[head] + lens) dp = next_dp[:] print(dp[-1]) if __name__ == '__main__': resolve()