結果

問題 No.1512 作文
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-21 21:31:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 514 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 82,944 KB
実行使用メモリ 104,704 KB
最終ジャッジ日時 2024-04-18 14:37:13
合計ジャッジ時間 6,099 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,840 KB
testcase_01 AC 42 ms
51,968 KB
testcase_02 AC 43 ms
51,968 KB
testcase_03 AC 42 ms
51,840 KB
testcase_04 AC 386 ms
90,880 KB
testcase_05 AC 382 ms
90,624 KB
testcase_06 AC 378 ms
90,624 KB
testcase_07 AC 373 ms
90,496 KB
testcase_08 AC 377 ms
91,136 KB
testcase_09 AC 56 ms
66,944 KB
testcase_10 AC 56 ms
67,200 KB
testcase_11 AC 57 ms
66,688 KB
testcase_12 AC 56 ms
67,328 KB
testcase_13 AC 55 ms
66,816 KB
testcase_14 AC 97 ms
76,544 KB
testcase_15 AC 98 ms
76,672 KB
testcase_16 AC 91 ms
76,032 KB
testcase_17 AC 99 ms
76,288 KB
testcase_18 AC 98 ms
76,416 KB
testcase_19 AC 103 ms
76,416 KB
testcase_20 AC 95 ms
76,416 KB
testcase_21 AC 47 ms
57,984 KB
testcase_22 AC 46 ms
57,344 KB
testcase_23 AC 47 ms
58,752 KB
testcase_24 AC 46 ms
58,752 KB
testcase_25 AC 47 ms
58,752 KB
testcase_26 AC 41 ms
52,224 KB
testcase_27 AC 42 ms
52,096 KB
testcase_28 AC 41 ms
51,840 KB
testcase_29 AC 40 ms
52,096 KB
testcase_30 AC 41 ms
51,968 KB
testcase_31 AC 47 ms
58,112 KB
testcase_32 AC 47 ms
58,880 KB
testcase_33 AC 46 ms
58,240 KB
testcase_34 AC 50 ms
59,776 KB
testcase_35 AC 55 ms
67,200 KB
testcase_36 AC 55 ms
67,456 KB
testcase_37 AC 52 ms
63,616 KB
testcase_38 AC 59 ms
68,480 KB
testcase_39 AC 64 ms
70,144 KB
testcase_40 AC 514 ms
104,704 KB
testcase_41 AC 237 ms
103,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0