結果

問題 No.1512 作文
ユーザー otsunekootsuneko
提出日時 2021-05-22 00:12:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 678 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 172,416 KB
最終ジャッジ日時 2024-04-18 17:06:42
合計ジャッジ時間 6,431 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,480 KB
testcase_01 AC 38 ms
52,608 KB
testcase_02 AC 38 ms
52,864 KB
testcase_03 AC 39 ms
52,864 KB
testcase_04 AC 442 ms
124,088 KB
testcase_05 AC 449 ms
124,040 KB
testcase_06 AC 449 ms
125,248 KB
testcase_07 AC 445 ms
125,600 KB
testcase_08 AC 440 ms
124,096 KB
testcase_09 AC 39 ms
53,632 KB
testcase_10 AC 39 ms
54,016 KB
testcase_11 AC 39 ms
53,376 KB
testcase_12 AC 41 ms
53,376 KB
testcase_13 AC 41 ms
53,888 KB
testcase_14 AC 85 ms
76,660 KB
testcase_15 AC 84 ms
76,544 KB
testcase_16 AC 87 ms
76,800 KB
testcase_17 AC 82 ms
76,696 KB
testcase_18 AC 82 ms
76,684 KB
testcase_19 AC 87 ms
76,740 KB
testcase_20 AC 85 ms
76,868 KB
testcase_21 AC 39 ms
52,608 KB
testcase_22 AC 38 ms
52,556 KB
testcase_23 AC 39 ms
52,864 KB
testcase_24 AC 40 ms
52,736 KB
testcase_25 AC 42 ms
52,864 KB
testcase_26 AC 39 ms
52,480 KB
testcase_27 AC 38 ms
52,864 KB
testcase_28 AC 37 ms
52,096 KB
testcase_29 AC 38 ms
52,224 KB
testcase_30 AC 39 ms
52,480 KB
testcase_31 AC 41 ms
59,008 KB
testcase_32 AC 42 ms
58,880 KB
testcase_33 AC 42 ms
58,420 KB
testcase_34 AC 46 ms
62,080 KB
testcase_35 AC 47 ms
71,936 KB
testcase_36 AC 47 ms
71,936 KB
testcase_37 AC 45 ms
66,304 KB
testcase_38 AC 56 ms
76,160 KB
testcase_39 AC 57 ms
76,416 KB
testcase_40 AC 678 ms
172,416 KB
testcase_41 AC 388 ms
162,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter
import sys
input = lambda: sys.stdin.readline().rstrip()
#INF = 10**18

N = int(input())
l = []
total = 0
for i in range(N):
    S = input()
    for i in range(len(S)-1):
        if S[i] > S[i+1]:
            break
    else:
        l.append([ord(S[0])-97,ord(S[-1])-97,len(S)])
l.sort(key=itemgetter(1,0))

dp = [[0]*26 for _ in range(len(l)+1)]

for i in range(len(l)):
    for j in range(26):
        if j >= l[i][1]:
            dp[i+1][j] = max(dp[i][l[i][0]] + l[i][2], dp[i][l[i][1]])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[len(l)][25])
0