結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 188 ms
80,648 KB
testcase_03 AC 183 ms
80,684 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 174 ms
80,764 KB
testcase_10 AC 181 ms
80,976 KB
testcase_11 AC 174 ms
80,892 KB
testcase_12 AC 181 ms
80,860 KB
testcase_13 AC 174 ms
80,884 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 176 ms
81,004 KB
testcase_22 AC 173 ms
80,756 KB
testcase_23 AC 172 ms
80,988 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 184 ms
80,664 KB
testcase_27 AC 177 ms
80,772 KB
testcase_28 AC 178 ms
80,676 KB
testcase_29 AC 174 ms
80,880 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 187 ms
83,472 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 199 ms
83,480 KB
testcase_36 AC 189 ms
83,428 KB
testcase_37 AC 187 ms
83,484 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 307 ms
92,068 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