結果

問題 No.1512 作文
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-21 21:26:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 104,492 KB
最終ジャッジ日時 2024-04-18 14:26:47
合計ジャッジ時間 5,344 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 WA -
testcase_02 AC 39 ms
51,968 KB
testcase_03 AC 35 ms
51,968 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 43 ms
66,816 KB
testcase_10 AC 44 ms
67,328 KB
testcase_11 AC 43 ms
67,200 KB
testcase_12 AC 45 ms
66,944 KB
testcase_13 AC 44 ms
66,816 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 39 ms
58,240 KB
testcase_22 AC 39 ms
58,112 KB
testcase_23 AC 39 ms
59,008 KB
testcase_24 AC 39 ms
58,880 KB
testcase_25 WA -
testcase_26 AC 35 ms
51,968 KB
testcase_27 AC 36 ms
51,840 KB
testcase_28 WA -
testcase_29 AC 36 ms
51,840 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 45 ms
66,944 KB
testcase_36 AC 45 ms
67,072 KB
testcase_37 AC 42 ms
63,872 KB
testcase_38 AC 48 ms
69,632 KB
testcase_39 AC 50 ms
70,272 KB
testcase_40 AC 443 ms
104,492 KB
testcase_41 AC 253 ms
103,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
cand = []
for _ in range(N):
    S = [ord(s) - 97 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] * 26
for s, t, l in cand:
    ndp = [0] * 26
    for x in range(s+1):
        ndp[t] = max(ndp[t], dp[x] + l)
    dp = ndp
print(max(dp))
0