結果

問題 No.1512 作文
ユーザー c-yanc-yan
提出日時 2021-05-21 21:56:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 581 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 85,376 KB
最終ジャッジ日時 2024-04-18 15:18:13
合計ジャッジ時間 6,069 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,968 KB
testcase_01 AC 36 ms
52,096 KB
testcase_02 AC 35 ms
51,688 KB
testcase_03 AC 38 ms
51,840 KB
testcase_04 AC 366 ms
82,048 KB
testcase_05 AC 377 ms
82,456 KB
testcase_06 AC 400 ms
82,228 KB
testcase_07 AC 398 ms
82,432 KB
testcase_08 AC 375 ms
82,304 KB
testcase_09 AC 69 ms
64,384 KB
testcase_10 AC 68 ms
64,512 KB
testcase_11 AC 66 ms
64,256 KB
testcase_12 AC 71 ms
64,640 KB
testcase_13 AC 70 ms
64,768 KB
testcase_14 AC 111 ms
77,184 KB
testcase_15 AC 95 ms
76,920 KB
testcase_16 AC 105 ms
76,932 KB
testcase_17 AC 97 ms
77,056 KB
testcase_18 AC 107 ms
77,312 KB
testcase_19 AC 99 ms
77,472 KB
testcase_20 AC 105 ms
76,920 KB
testcase_21 AC 37 ms
53,120 KB
testcase_22 AC 34 ms
52,480 KB
testcase_23 AC 37 ms
53,888 KB
testcase_24 AC 37 ms
54,400 KB
testcase_25 AC 36 ms
53,760 KB
testcase_26 AC 37 ms
52,080 KB
testcase_27 AC 34 ms
51,964 KB
testcase_28 AC 34 ms
51,840 KB
testcase_29 AC 33 ms
51,584 KB
testcase_30 AC 33 ms
52,096 KB
testcase_31 AC 34 ms
51,840 KB
testcase_32 AC 34 ms
52,352 KB
testcase_33 AC 36 ms
52,080 KB
testcase_34 AC 44 ms
62,592 KB
testcase_35 AC 45 ms
62,720 KB
testcase_36 AC 43 ms
62,720 KB
testcase_37 AC 37 ms
58,160 KB
testcase_38 AC 56 ms
72,192 KB
testcase_39 AC 51 ms
72,704 KB
testcase_40 AC 581 ms
85,376 KB
testcase_41 AC 332 ms
83,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [input() for _ in range(N)]

S.sort()

dp = {}
#for c in 'abcdefghijklmnopqrstuvwxyz':
#    dp[c] = -1
dp[chr(ord('a')-1)]=0

for l in S:
    #print("*", l)
    if ''.join(sorted(l)) != l:
        continue
    lc = l[-1]
    for c in reversed('abcdefghijklmnopqrstuvwxyz'):
        if c not in dp:
            continue
        if l[0] < c:
            continue
        #print(c, dp[lc])
        if lc not in dp:
            dp[lc] = dp[c] + len(l)
        else:
            dp[lc] = max(dp[lc], dp[c] + len(l))
        #print(c, dp[lc])
    if lc not in dp:
        dp[lc] = len(l)
    else:
        dp[lc] = max(dp[lc], len(l))
    #print(l)
    #print(dp)
print(max(dp.values()))
0