結果

問題 No.1512 作文
ユーザー tcltktcltk
提出日時 2021-06-25 16:27:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 1,106 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 92,380 KB
最終ジャッジ日時 2023-09-07 13:36:40
合計ジャッジ時間 10,193 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 178 ms
80,984 KB
testcase_03 AC 175 ms
80,844 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 177 ms
80,976 KB
testcase_10 AC 180 ms
80,836 KB
testcase_11 AC 181 ms
80,932 KB
testcase_12 AC 180 ms
80,988 KB
testcase_13 AC 178 ms
80,780 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 180 ms
80,912 KB
testcase_22 AC 175 ms
80,992 KB
testcase_23 AC 177 ms
80,668 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 163 ms
80,864 KB
testcase_27 AC 175 ms
80,860 KB
testcase_28 AC 171 ms
81,024 KB
testcase_29 AC 171 ms
80,964 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 177 ms
83,552 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 192 ms
83,668 KB
testcase_36 AC 183 ms
83,324 KB
testcase_37 AC 177 ms
83,308 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 288 ms
91,940 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 = """3
# ab
# cd
# f
# """
# sys.stdin = io.StringIO(_INPUT)


N = int(input())
S = [input()for _ in range(N)]

dp = [0] * 26
for s in S:
    
    ok = True
    for i in range(len(s)-1):
        if s[i] > s[i+1]:
            ok = False
            break
    if not ok:
        continue

    dp1 = [0] * 26
    k1 = ord(s[0])-ord('a')
    k2 = ord(s[-1])-ord('a')
    for k in range(k1+1):
        dp1[k] = max(dp1[k], dp[k])
        dp1[k2] = max(dp1[k2], dp[k]+len(s))
    dp = dp1

ans = max(dp)
print(ans)
0