結果
| 問題 | No.1512 作文 |
| コンテスト | |
| ユーザー |
koheijkt
|
| 提出日時 | 2026-02-07 00:06:23 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 539 ms / 2,000 ms |
| コード長 | 916 bytes |
| 記録 | |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 82,612 KB |
| 実行使用メモリ | 115,248 KB |
| 最終ジャッジ日時 | 2026-02-07 00:06:31 |
| 合計ジャッジ時間 | 7,447 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 38 |
ソースコード
import sys, math
sys.setrecursionlimit(10**8)
sys.set_int_max_str_digits(0)
INF = 1e18
MOD = 998244353
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def I(): return input().rstrip()
def II(): return int(input().rstrip())
def chmax(DP,i,v):
if DP[i] < v: DP[i] = v
def chmin(DP,i,v):
if DP[i] > v: DP[i] = v
N = II()
S = []
for i in range(N):
s = I()
# s が良い文字列か?
pre = 0
for ss in s:
now = ord(ss) - 97
if pre > now:
break
pre = now
else:
S.append((ord(s[0]) - 97, ord(s[-1]) - 97, len(s)))
S.sort(key=lambda x: (x[0], x[1]))
DP = [0] * 26
for src, dst, l in S:
chmax(DP, dst, max(DP[:src + 1]) + l)
print(max(DP))
koheijkt