結果

問題 No.1512 作文
ユーザー tassei903tassei903
提出日時 2021-05-21 22:26:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 177,176 KB
最終ジャッジ日時 2024-04-18 15:58:04
合計ジャッジ時間 6,729 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,196 KB
testcase_01 AC 34 ms
53,292 KB
testcase_02 AC 34 ms
52,960 KB
testcase_03 AC 37 ms
53,944 KB
testcase_04 AC 458 ms
126,084 KB
testcase_05 AC 439 ms
126,288 KB
testcase_06 AC 438 ms
126,316 KB
testcase_07 AC 444 ms
126,304 KB
testcase_08 AC 444 ms
126,712 KB
testcase_09 AC 37 ms
54,380 KB
testcase_10 AC 33 ms
54,724 KB
testcase_11 AC 37 ms
54,992 KB
testcase_12 AC 34 ms
53,852 KB
testcase_13 AC 36 ms
55,168 KB
testcase_14 AC 94 ms
77,608 KB
testcase_15 AC 101 ms
77,632 KB
testcase_16 AC 98 ms
77,820 KB
testcase_17 AC 101 ms
77,544 KB
testcase_18 AC 98 ms
77,884 KB
testcase_19 AC 100 ms
77,752 KB
testcase_20 AC 93 ms
78,184 KB
testcase_21 AC 38 ms
53,220 KB
testcase_22 AC 37 ms
52,136 KB
testcase_23 AC 38 ms
53,040 KB
testcase_24 AC 39 ms
53,628 KB
testcase_25 AC 39 ms
52,436 KB
testcase_26 AC 38 ms
52,836 KB
testcase_27 AC 36 ms
52,336 KB
testcase_28 AC 36 ms
52,408 KB
testcase_29 AC 37 ms
53,228 KB
testcase_30 AC 37 ms
52,104 KB
testcase_31 AC 42 ms
59,256 KB
testcase_32 AC 41 ms
59,116 KB
testcase_33 AC 41 ms
58,776 KB
testcase_34 AC 49 ms
64,124 KB
testcase_35 AC 48 ms
71,976 KB
testcase_36 AC 45 ms
72,304 KB
testcase_37 AC 42 ms
67,308 KB
testcase_38 AC 59 ms
75,432 KB
testcase_39 AC 60 ms
75,444 KB
testcase_40 AC 706 ms
177,176 KB
testcase_41 AC 421 ms
175,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = [input() for i in range(n)]

z = []
for i in range(n):
    b = True
    for j in range(len(s[i])-1):
        if s[i][j] > s[i][j+1]:
            b = False
            break
    if b:
        z.append((ord(s[i][0])-97,ord(s[i][-1])-97,len(s[i])))

z = sorted(z,key = lambda x:(x[1],x[0]))
m = len(z)
dp = [[0 for i in range(26)] for j in range(m+1)]
for i in range(m):
    for j in range(26):
        dp[i+1][j] = dp[i][j]
    for j in range(0,z[i][0]+1):
        dp[i+1][z[i][1]] = max(dp[i+1][z[i][1]],dp[i][j]+z[i][2])
print(max(dp[-1]))
0