結果
| 問題 | No.1512 作文 |
| コンテスト | |
| ユーザー |
strangerxxx
|
| 提出日時 | 2021-05-21 22:17:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,568 ms / 2,000 ms |
| コード長 | 566 bytes |
| 記録 | |
| コンパイル時間 | 128 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 16,776 KB |
| 最終ジャッジ日時 | 2024-10-10 09:03:04 |
| 合計ジャッジ時間 | 10,018 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
def resolve():
n = int(input())
chars = ord("z") - ord("a") + 1
dp = [0] * (chars)
next_dp = dp[:]
l = [input() for _ in range(n)]
for s in sorted(l):
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()
strangerxxx