結果

問題 No.1512 作文
ユーザー tcltktcltk
提出日時 2021-06-25 16:41:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 126,540 KB
最終ジャッジ日時 2023-09-07 13:37:13
合計ジャッジ時間 12,057 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 206 ms
80,960 KB
testcase_02 AC 200 ms
80,996 KB
testcase_03 AC 201 ms
80,932 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 199 ms
80,856 KB
testcase_10 AC 199 ms
80,840 KB
testcase_11 AC 200 ms
81,012 KB
testcase_12 AC 196 ms
80,964 KB
testcase_13 AC 199 ms
81,036 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 204 ms
80,932 KB
testcase_22 AC 202 ms
80,876 KB
testcase_23 AC 207 ms
80,932 KB
testcase_24 AC 201 ms
80,932 KB
testcase_25 WA -
testcase_26 AC 197 ms
80,780 KB
testcase_27 AC 204 ms
80,920 KB
testcase_28 AC 200 ms
80,752 KB
testcase_29 AC 203 ms
80,932 KB
testcase_30 AC 199 ms
80,912 KB
testcase_31 AC 204 ms
81,612 KB
testcase_32 AC 199 ms
81,520 KB
testcase_33 AC 203 ms
81,348 KB
testcase_34 AC 211 ms
83,992 KB
testcase_35 AC 208 ms
83,828 KB
testcase_36 AC 216 ms
83,856 KB
testcase_37 AC 206 ms
83,340 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 386 ms
125,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """4
# abc
# ab
# bbccdd
# de
# """
# sys.stdin = io.StringIO(_INPUT)


N = int(input())
S = [input() for _ in range(N)]
L = []
for s in S:
    ok = True
    for i in range(len(s)-1):
        if s[i] > s[i+1]:
            ok = False
            break
    if ok:
        L.append((ord(s[0])-ord('a'), ord(s[-1])-ord('a'), len(s)))
# L.sort(key=lambda x: (x[0], x[1], -x[2]))

dp = [0] * 26
for k1, k2, l in L:

    dp1 = [0] * 26
    for k in range(26):
        dp1[k] = max(dp1[k], dp[k])
        if k <= k1:
            dp1[k2] = max(dp1[k2], dp[k]+l)
    dp = dp1

ans = max(dp)
print(ans)
0