結果

問題 No.1512 作文
ユーザー DrDrpilotDrDrpilot
提出日時 2022-06-02 13:03:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 181,136 KB
最終ジャッジ日時 2023-10-21 01:06:42
合計ジャッジ時間 7,821 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,256 KB
testcase_01 AC 37 ms
52,072 KB
testcase_02 AC 38 ms
52,072 KB
testcase_03 AC 38 ms
52,056 KB
testcase_04 AC 506 ms
129,640 KB
testcase_05 AC 494 ms
129,336 KB
testcase_06 AC 496 ms
130,084 KB
testcase_07 AC 503 ms
129,404 KB
testcase_08 AC 503 ms
129,808 KB
testcase_09 AC 56 ms
73,872 KB
testcase_10 AC 56 ms
74,468 KB
testcase_11 AC 55 ms
73,900 KB
testcase_12 AC 57 ms
74,868 KB
testcase_13 AC 54 ms
74,040 KB
testcase_14 AC 162 ms
77,756 KB
testcase_15 AC 137 ms
77,184 KB
testcase_16 AC 142 ms
77,060 KB
testcase_17 AC 148 ms
76,768 KB
testcase_18 AC 155 ms
77,080 KB
testcase_19 AC 148 ms
76,796 KB
testcase_20 AC 156 ms
77,108 KB
testcase_21 AC 45 ms
59,868 KB
testcase_22 AC 43 ms
59,868 KB
testcase_23 AC 46 ms
61,916 KB
testcase_24 AC 46 ms
61,916 KB
testcase_25 AC 46 ms
61,916 KB
testcase_26 AC 39 ms
53,628 KB
testcase_27 AC 38 ms
53,628 KB
testcase_28 AC 38 ms
53,628 KB
testcase_29 AC 38 ms
53,628 KB
testcase_30 AC 38 ms
53,628 KB
testcase_31 AC 45 ms
59,948 KB
testcase_32 AC 48 ms
59,944 KB
testcase_33 AC 44 ms
59,940 KB
testcase_34 AC 55 ms
66,484 KB
testcase_35 AC 61 ms
87,188 KB
testcase_36 AC 62 ms
87,184 KB
testcase_37 AC 54 ms
76,128 KB
testcase_38 AC 69 ms
76,348 KB
testcase_39 AC 72 ms
76,552 KB
testcase_40 AC 700 ms
180,548 KB
testcase_41 AC 439 ms
181,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
lis=[]
ch='abcdefghijklmnopqrstuvwxyz'
for _ in range(n):
    s=input()
    tmp=[]
    for i in range(len(s)):
        tmp.append(ch.index(s[i]))
    f=True
    for i in range(len(s)-1):
        if s[i]>s[i+1]:
            f=False
            break
    if f:
        lis.append(tmp)
if len(lis)==0:
    exit(print(0))
L=[]
for t in lis:
    L.append((t[0],t[-1],len(t)))
L.sort()
N=len(L)
dp=[[0]*26 for _ in range(N+1)]
for i in range(N):
    l,r,d=L[i][0],L[i][1],L[i][2]
    for k in range(l+1):
        dp[i+1][r]=max(dp[i][r],dp[i][k]+d,dp[i+1][r])
    for j in range(26):
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])
print(max(dp[-1]))
0