結果
| 問題 |
No.1512 作文
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2021-05-21 21:31:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 474 ms / 2,000 ms |
| コード長 | 515 bytes |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 81,940 KB |
| 実行使用メモリ | 104,000 KB |
| 最終ジャッジ日時 | 2024-10-10 07:51:33 |
| 合計ジャッジ時間 | 5,776 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
cand = []
for _ in range(N):
S = [ord(s) - 97 + 1 for s in input().rstrip()]
L = len(S)
ok = True
for i in range(L-1):
if S[i] > S[i+1]:
ok = False
break
if not ok:
continue
cand.append((S[0], S[-1], L))
cand.sort()
dp = [0] * 27
for s, t, l in cand:
ndp = dp.copy()
for x in range(s+1):
ndp[t] = max(ndp[t], dp[x] + l)
dp = ndp
print(max(dp))
tktk_snsn