結果

問題 No.1512 作文
ユーザー ygd.ygd.
提出日時 2021-05-21 21:33:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 105,028 KB
最終ジャッジ日時 2024-04-18 14:43:12
合計ジャッジ時間 5,484 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,988 KB
testcase_01 AC 36 ms
52,268 KB
testcase_02 AC 36 ms
52,748 KB
testcase_03 AC 39 ms
52,680 KB
testcase_04 AC 342 ms
90,240 KB
testcase_05 AC 328 ms
90,200 KB
testcase_06 AC 321 ms
90,100 KB
testcase_07 AC 353 ms
90,088 KB
testcase_08 AC 351 ms
90,188 KB
testcase_09 AC 38 ms
53,428 KB
testcase_10 AC 38 ms
53,556 KB
testcase_11 AC 41 ms
54,752 KB
testcase_12 AC 39 ms
54,216 KB
testcase_13 AC 38 ms
55,236 KB
testcase_14 AC 89 ms
76,644 KB
testcase_15 AC 92 ms
76,584 KB
testcase_16 AC 94 ms
76,548 KB
testcase_17 AC 92 ms
76,672 KB
testcase_18 AC 89 ms
76,548 KB
testcase_19 AC 92 ms
76,584 KB
testcase_20 AC 91 ms
76,532 KB
testcase_21 AC 38 ms
52,976 KB
testcase_22 AC 37 ms
53,104 KB
testcase_23 AC 39 ms
53,676 KB
testcase_24 AC 40 ms
54,920 KB
testcase_25 AC 41 ms
52,736 KB
testcase_26 AC 37 ms
52,480 KB
testcase_27 AC 37 ms
52,132 KB
testcase_28 AC 36 ms
53,420 KB
testcase_29 AC 38 ms
52,432 KB
testcase_30 AC 38 ms
52,608 KB
testcase_31 AC 39 ms
59,136 KB
testcase_32 AC 42 ms
58,252 KB
testcase_33 AC 42 ms
58,668 KB
testcase_34 AC 45 ms
59,908 KB
testcase_35 AC 48 ms
71,712 KB
testcase_36 AC 49 ms
71,588 KB
testcase_37 AC 42 ms
66,408 KB
testcase_38 AC 49 ms
72,452 KB
testcase_39 AC 50 ms
72,724 KB
testcase_40 AC 466 ms
105,028 KB
testcase_41 AC 204 ms
96,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(x):
    n = len(x)
    for i in range(n-1):
        if x[i] > x[i+1]:
            return False
    return True


n = int(input())
L = []
for i in range(n):
    s = str(input())
    if check(s):
        first = ord(s[0]) - 97
        last = ord(s[-1]) - 97
        L.append((first,last,len(s)))
L.sort()
#print(L)

dp = [0]*26
for first, last, length in L:
    dp[last] = max(dp[last], max(dp[:first+1]) + length)
#print(dp)
ans = max(dp)
print(ans)
0